private void OnGUI() { actorMeshPrefab = (GameObject)EditorGUILayout.ObjectField(actorMeshPrefab, typeof(GameObject), false); EditorGUILayout.Space(10); if (actorMeshPrefab == null) { return; } if (GUILayout.Button("Create Player", GUILayout.Height(30))) { actor = new GameObject(actorMeshPrefab.name); ActorController controller = actor.AddComponent <DefaultActorController>(); controller.model = actor.GetComponent <ActorModel>(); // Add Character Mesh object GameObject meshObj = PrefabUtility.InstantiatePrefab(actorMeshPrefab) as GameObject; meshObj.transform.SetParent(actor.transform); if (meshObj.GetComponent <Animator>()) { meshObj.GetComponent <Animator>().applyRootMotion = false; } else { meshObj.AddComponent <Animator>().applyRootMotion = false; } // Add HitbBox GameObject hitBoxGO = GameObject.CreatePrimitive(PrimitiveType.Cube); hitBoxGO.name = "HitBox"; hitBoxGO.transform.SetParent(actor.transform); hitBoxGO.AddComponent <HitBox>(); hitBoxGO.GetComponent <Rigidbody>().isKinematic = true; hitBoxGO.GetComponent <LineRenderer>().enabled = false; ColliderVisualizer hitBoxVisualizer = hitBoxGO.GetComponent <ColliderVisualizer>(); hitBoxVisualizer.lineColor = new Color(0, 0.72f, 1f, 1f); MeshRenderer hitBoxRenderer = hitBoxGO.GetComponent <MeshRenderer>(); hitBoxRenderer.material = (Material)AssetDatabase.LoadAssetAtPath("Assets/Plugins/CombatDesigner/Artworks/Materials/HitBoxMat.mat", typeof(Material)); hitBoxRenderer.enabled = false; SettingUtils.AddLayer("HitBox"); hitBoxGO.layer = LayerMask.NameToLayer("HitBox"); // Add HurtBox GameObject hurtBoxGO = GameObject.CreatePrimitive(PrimitiveType.Cube); hurtBoxGO.name = "HurtBox"; hurtBoxGO.transform.SetParent(actor.transform); hurtBoxGO.AddComponent <HurtBox>(); hurtBoxGO.GetComponent <LineRenderer>().enabled = false; ColliderVisualizer hurtBoxVisualizer = hurtBoxGO.GetComponent <ColliderVisualizer>(); hurtBoxVisualizer.lineColor = new Color(1, 0.06f, 0.06f, 1); MeshRenderer hurtBoxRenderer = hurtBoxGO.GetComponent <MeshRenderer>(); hurtBoxRenderer.material = (Material)AssetDatabase.LoadAssetAtPath("Assets/Plugins/CombatDesigner/Artworks/Materials/HurtBoxMat.mat", typeof(Material)); hurtBoxRenderer.enabled = false; SettingUtils.AddLayer("HurtBox"); hurtBoxGO.layer = LayerMask.NameToLayer("HurtBox"); } }
public void InitVisualizer(ColliderVisualizer.VisualizerColorType vColor) { ColliderVisualizer visualizer = GetComponent <ColliderVisualizer>(); var message = ""; var fontSize = 36; visualizer.Initialize(vColor, message, fontSize); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); // show the original GUI content // Assign the target object ColliderVisualizer colliderVisualizer = target as ColliderVisualizer; if (colliderVisualizer == null) { return; } Collider col = colliderVisualizer.GetComponent <Collider>(); GUILayout.Label("Visualizer Type:" + col); // A Btn for Updating the Collider Visualizer if (GUILayout.Button("UpdateVisualizer")) { LineRenderer lr = colliderVisualizer.GetComponent <LineRenderer>(); MeshRenderer mr = colliderVisualizer.GetComponent <MeshRenderer>(); if (lr != null) { lr.enabled = true; } if (mr != null) { mr.enabled = true; } colliderVisualizer.Init(); } // A Btn for Closing the Collider Visualizer if (GUILayout.Button("CloseVisualizer")) { LineRenderer lr = colliderVisualizer.GetComponent <LineRenderer>(); MeshRenderer mr = colliderVisualizer.GetComponent <MeshRenderer>(); if (lr != null) { lr.enabled = false; } if (mr != null) { mr.enabled = false; } } }