本文整理汇总了C#中UnityEngine.MeshRenderer.GetInstanceID方法的典型用法代码示例。如果您正苦于以下问题:C# MeshRenderer.GetInstanceID方法的具体用法?C# MeshRenderer.GetInstanceID怎么用?C# MeshRenderer.GetInstanceID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.MeshRenderer
的用法示例。
在下文中一共展示了MeshRenderer.GetInstanceID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInspectorGUI
public override void OnInspectorGUI ()
{
this.DrawDefaultInspector();
EditorGUI.indentLevel = 0;
foldout = EditorGUILayout.Foldout(foldout, "MeshRenderer AABB");
if (foldout) {
EditorGUI.indentLevel = 2;
bool newIsAABBenabled = EditorGUILayout.Toggle(STR_ENABLE_MESH_AABB,isAABBenabled);
if (newIsAABBenabled != isAABBenabled) {
isAABBenabled = newIsAABBenabled;
EditorUtility.SetDirty(this.target);
}
// Update status of the "Keep AABB visible" checkbox (optimize this by doing the search in storedSelections dictionary only when the current selection changes)
if (currentSelection != this.target) {
currentSelection = this.target as MeshRenderer;
// check if this MeshRenderer is already in the stored selections
isKeepAABBVisible = storedSelections.ContainsKey(currentSelection.GetInstanceID());
//Debug.Log("isKeepAABBVisible current status: " + isKeepAABBVisible);
}
bool newIsKeepAABBVisible = EditorGUILayout.Toggle(STR_KEEP_VISIBLE, isKeepAABBVisible);
if (newIsKeepAABBVisible != isKeepAABBVisible) {
if (newIsKeepAABBVisible) {
Transform[] multiSelection = Selection.transforms;
// check for multi selection
if (multiSelection.Length > 1) {
for(int i = 0; i < multiSelection.Length; i++) {
if ( multiSelection[i].renderer && !storedSelections.ContainsKey((multiSelection[i].renderer as MeshRenderer).GetInstanceID()) ) {
storedSelections.Add( (multiSelection[i].renderer as MeshRenderer).GetInstanceID(), multiSelection[i].renderer as MeshRenderer);
}
}
} else {
// add current mesh renderer to the stored selection dictionary to have the AABB always highlighted
storedSelections.Add(currentSelection.GetInstanceID(), currentSelection);
}
} else {
Transform[] multiSelection = Selection.transforms;
// check for multi-selection
if (multiSelection.Length > 1) {
for(int i = 0; i < multiSelection.Length; i++) {
if ( multiSelection[i].renderer && storedSelections.ContainsKey((multiSelection[i].renderer as MeshRenderer).GetInstanceID()) ) {
storedSelections.Remove( (multiSelection[i].renderer as MeshRenderer).GetInstanceID() );
}
}
} else {
// remove current MeshRenderer from the storeSelections dictionary
storedSelections.Remove(currentSelection.GetInstanceID());
}
}
EditorUtility.SetDirty(this.target);
// force refresh of the "Keep AABB visible" checkbox status
currentSelection = null;
}
// Display current AABB bounds size
if (currentSelection != null) {
EditorGUILayout.SelectableLabel("Bounds Size:" + currentSelection.bounds.size.ToString());
}
EditorGUILayout.Separator();
GUILayout.BeginVertical();
if ( GUILayout.Button(STR_CLEAR_ALL_VISIBLE, GUILayout.MaxWidth(200)) ) {
storedSelections.Clear();
cleanupList.Clear();
EditorUtility.SetDirty(this.target);
}
GUILayout.EndVertical();
}
}