protected void OnGUI()
    {
        if (Application.isPlaying)
        {
            GUILayout.Label("PLAY MODE ACTIVE", GUI.skin.box, GUILayout.ExpandWidth(true), GUILayout.MinHeight(32));//OYM:Play模式屏蔽了
            return;
        }

        GUILayout.Label("OPTIONS", GUI.skin.box, GUILayout.ExpandWidth(true), GUILayout.MinHeight(32));
        if (GUILayout.Button("Clean Up Objects"))
        {
            CleanUp();                                      //OYM:清理Object
        }
        GUILayout.Space(20);
        source = EditorGUILayout.ObjectField("Source", source, typeof(GameObject), true) as GameObject;//OYM:源文件

        if (Selection.activeGameObject != null)
        {
            //hack to not select preview chunks OR Points OR Destructible :)
            if (Selection.activeGameObject.GetComponent <ChunkInfo>() == null && Selection.activeGameObject.hideFlags != HideFlags.NotEditable && Selection.activeGameObject.GetComponent <Destructible>() == null)
            {
                if (Selection.activeGameObject.GetComponent <MeshFilter>() != null)
                {
                    source = Selection.activeGameObject;
                }
                if (Selection.activeGameObject.GetComponentInChildren <SkinnedMeshRenderer>() != null)//OYM:这个操作还是一如既往的迷啊...

                {
                    source = Selection.activeGameObject.GetComponentInChildren <SkinnedMeshRenderer>().gameObject;
                }
            }
        }

        if (!source)
        {
            return;
        }
        //OYM:没有就不管
        insideMaterial = (Material)EditorGUILayout.ObjectField("Inside Material", insideMaterial, typeof(Material), false);

        if (!insideMaterial)
        {
            return;
        }

        fractureType = (FractureTypes)EditorGUILayout.EnumPopup("Fracture Type", fractureType);//OYM:获取type

        EditorGUILayout.BeginHorizontal();
        islands          = EditorGUILayout.Toggle("Islands", islands);
        previewColliders = EditorGUILayout.Toggle("Preview Colliders", previewColliders);
        EditorGUILayout.EndHorizontal();

        seed = EditorGUILayout.IntSlider("Seed", seed, 0, 25);

        EditorGUI.BeginChangeCheck();
        previewDistance = EditorGUILayout.Slider("Preview", previewDistance, 0, 5);
        //OYM:获取各种属性
        if (EditorGUI.EndChangeCheck())
        {
            UpdatePreview();
        }

        bool canCreate = false;

        if (fractureType == FractureTypes.Voronoi)
        {
            canCreate = GUI_Voronoi();                                       //OYM:单纯的裂开
        }
        if (fractureType == FractureTypes.Clustered)
        {
            canCreate = GUI_Clustered();                                         //OYM:不知道,或许是在某一范围内炸开?
        }
        if (fractureType == FractureTypes.Slicing)
        {
            canCreate = GUI_Slicing();                                       //OYM:切片
        }
        if (fractureType == FractureTypes.Skinned)
        {
            canCreate = GUI_Skinned();                                       //OYM:切关节
        }
        if (fractureType == FractureTypes.Plane)
        {
            canCreate = GUI_Plane();
        }
        if (fractureType == FractureTypes.Cutout)
        {
            canCreate = GUI_Cutout();
        }

        if (canCreate)//OYM:反正就是只要是这几个界面都可以
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Preview Chunks"))
            {
                _createPreview(false);
            }

            if (GUILayout.Button("Create Prefab"))
            {
                _createPreview(true);
            }
            GUILayout.EndHorizontal();
        }
    }
예제 #2
0
    protected void OnGUI()
    {
        if (Application.isPlaying)
        {
            GUILayout.Label("PLAY MODE ACTIVE", GUI.skin.box, GUILayout.ExpandWidth(true), GUILayout.MinHeight(32));
            return;
        }

        GUILayout.Label("OPTIONS", GUI.skin.box, GUILayout.ExpandWidth(true), GUILayout.MinHeight(32));
        if (GUILayout.Button("Clean Up Objects"))
        {
            CleanUp();
        }

        // OLD CODE: Replaced by 'sourceList'
        //GUILayout.Space(20);
        //source = EditorGUILayout.ObjectField("Source", source, typeof(GameObject), true) as GameObject;

        // New Code: Enable the sourceList in the EditorWindow
        ScriptableObject target           = this;
        SerializedObject serializedObject = new SerializedObject(target);
        // We add 'sourceList' to our serialized property (the variable must be the same name)
        SerializedProperty serializedProperty = serializedObject.FindProperty("sourceList");

        // True here means show children
        EditorGUILayout.PropertyField(serializedProperty, true);
        serializedObject.ApplyModifiedProperties();

        // OLD CODE: Replaced by 'SourceList'
        //if (Selection.activeGameObject != null)
        //      {
        //          //hack to not select preview chunks OR Points OR Destructible :)
        //          if (Selection.activeGameObject.GetComponent<ChunkInfo>() == null && Selection.activeGameObject.hideFlags != HideFlags.NotEditable && Selection.activeGameObject.GetComponent<Destructible>() == null)
        //          {
        //              if (Selection.activeGameObject.GetComponent<MeshFilter>() != null) source = Selection.activeGameObject;
        //              if (Selection.activeGameObject.GetComponentInChildren<SkinnedMeshRenderer>() != null)
        //              {
        //                  source = Selection.activeGameObject.GetComponentInChildren<SkinnedMeshRenderer>().gameObject;
        //              }
        //          }
        //      }

        //      if (!source) return;

        insideMaterial = (Material)EditorGUILayout.ObjectField("Inside Material", insideMaterial, typeof(Material), false);

        if (!insideMaterial)
        {
            return;
        }

        fractureType = (FractureTypes)EditorGUILayout.EnumPopup("Fracture Type", fractureType);

        EditorGUILayout.BeginHorizontal();
        islands          = EditorGUILayout.Toggle("Islands", islands);
        previewColliders = EditorGUILayout.Toggle("Preview Colliders", previewColliders);
        EditorGUILayout.EndHorizontal();

        seed = EditorGUILayout.IntSlider("Seed", seed, 0, 25);

        EditorGUI.BeginChangeCheck();
        previewDistance = EditorGUILayout.Slider("Preview", previewDistance, 0, 5);
        if (EditorGUI.EndChangeCheck())
        {
            UpdatePreview(false);
        }

        bool canCreate = false;

        if (fractureType == FractureTypes.Voronoi)
        {
            canCreate = GUI_Voronoi();
        }
        if (fractureType == FractureTypes.Clustered)
        {
            canCreate = GUI_Clustered();
        }
        if (fractureType == FractureTypes.Slicing)
        {
            canCreate = GUI_Slicing();
        }
        if (fractureType == FractureTypes.Skinned)
        {
            canCreate = GUI_Skinned();
        }
        if (fractureType == FractureTypes.Plane)
        {
            canCreate = GUI_Plane();
        }
        if (fractureType == FractureTypes.Cutout)
        {
            canCreate = GUI_Cutout();
        }

        if (canCreate)
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Preview Chunks"))
            {
                _createPreview(false);
            }

            if (GUILayout.Button("Create Prefab"))
            {
                _createPreview(true);
            }
            GUILayout.EndHorizontal();
        }
    }