Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity trygetcomponent

Renderer rendererFound;
//If TryGetComponent doesn't find a Renderer on this, it returns false
//If a Renderer is found, it return true AND places the renderer that was 
//found into 'rendererFound'
if (TryGetComponent(out rendererFound) == false) 
{
  Debug.LogError($"Error in {GetType()}: GameObject doesn't have a Renderer object");
  return null;
}
//Use 'rendererFound' asif component was found
float halfRadius = rendererFound.bounds.size.z / 2;
Comment

PREVIOUS NEXT
Code Example
Csharp :: bezier_curve 
Csharp :: EF .NET4 INSERT IMPROVE PERFORMACE 
Csharp :: c# delete object 
Csharp :: addssdawsdawdsdawasdawasdawdswsddsdawssd 
Csharp :: logical operators in c# 
Csharp :: concurrent post request c# 
Csharp :: C# ToCsv Extension Method 
Csharp :: create a hash of an XML c# 
Csharp :: set time on audio source unity 
Csharp :: c sharp xml prettier 
Csharp :: hive survive 
Csharp :: c# list find null 
Csharp :: c# Prefix Sum of Matrix (Or 2D Array) 
Csharp :: pass viewbag selectlistitem to razor 
Csharp :: how to change argument of function in f# 
Csharp :: camera is rendering black screen unity 
Csharp :: c# multipthreading 
Csharp :: parent to children nextJs 
Csharp :: copy file image in c# 
Csharp :: prevent C# app from lingering after closing in background processes 
Csharp :: c# check if float value is positif 
Csharp :: set-variables-from-an-object-using-reflection 
Csharp :: linqkit predicatebuilder or and nested combined predicates 
Csharp :: unity soundclip mix 
Csharp :: 1/1/1/1/1 
Csharp :: c# remove numericUpDown white space 
Csharp :: streamwriter delete all text 
Csharp :: c# variable 
Csharp :: "; expected" error c#$ 
Csharp :: telerik mvc grid scroll 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =