Ejemplo n.º 1
0
    void OnGUI()
    {
        titleContent.text = "打包设置编辑器";

        UpdateRelyPackageNames();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("过滤器:");

        RelyMaskFilter = EditorGUILayout.MaskField(RelyMaskFilter, RelyPackageNames);
        bundleQuery    = EditorGUILayout.TextField("", bundleQuery);
        EditorGUILayout.EndHorizontal();

        scrollPos = GUILayout.BeginScrollView(scrollPos);

        isFoldRelyPackages = EditorGUILayout.Foldout(isFoldRelyPackages, "依赖包:");
        if (isFoldRelyPackages)
        {
            //依赖包视图
            RelyPackagesView();

            EditorGUILayout.Space();
        }

        EditorGUI.indentLevel = 0;
        isFoldBundles         = EditorGUILayout.Foldout(isFoldBundles, "AssetsBundle:");
        if (isFoldBundles)
        {
            //bundle包视图
            BundlesView();
        }

        GUILayout.EndScrollView();

        EditorGUI.indentLevel = 0;
        GUILayout.BeginHorizontal();

        checkMaterial = EditorGUILayout.Toggle("检查材质球和贴图", checkMaterial);

        GUILayout.EndHorizontal();

        if (GUILayout.Button("检查依赖关系"))
        {
            CheckPackage();
        }

        if (GUILayout.Button("保存编辑器设置文件"))
        {
            CreatPackageFile();
        }

        if (GUILayout.Button("生成游戏资源路径文件"))
        {
            CheckAndCreatBundelPackageConfig();
        }

        if (GUILayout.Button("打包 并生成MD5文件"))
        {
            CheckAndPackage();
        }

        if (GUILayout.Button("生成MD5"))
        {
            CheckAndCreatBundelPackageConfig();
        }

        GUILayout.BeginHorizontal();

        largeVersion = EditorGUILayout.IntField("large", largeVersion);
        smallVersion = EditorGUILayout.IntField("small", smallVersion);

        if (GUILayout.Button("保存版本文件"))
        {
            CreatVersionFile();
        }

        GUILayout.EndHorizontal();

        if (isContent)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(messageContent);

            if (GUILayout.Button("关闭"))
            {
                isContent      = false;
                messageContent = "";
            }

            if (errorCount != 0 || warnCount != 0)
            {
                if (GUILayout.Button("清除"))
                {
                    isContent      = false;
                    messageContent = "";

                    ClearCheckLog();
                }
            }
            EditorGUILayout.EndHorizontal();
        }

        if (isProgress)
        {
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUI.ProgressBar(new Rect(3, position.height - 22, position.width - 6, 18), progress, progressContent);
        }
    }
Ejemplo n.º 2
0
        public override void OnInspectorGUI()
        {   
            SerializedProperty streamDescriptorObj = serializedObject.FindProperty("streamDescriptor");
            SerializedProperty startTime = serializedObject.FindProperty("startTime");
            SerializedProperty endTime = serializedObject.FindProperty("endTime");

            var streamPlayer = target as AlembicStreamPlayer;
            var targetStreamDesc = streamPlayer.streamDescriptor;
            var multipleTimeRanges = false;
            foreach (AlembicStreamPlayer player in targets)
            {
                //
            }

            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.ObjectField(streamDescriptorObj);
            EditorGUI.EndDisabledGroup();
            if (streamDescriptorObj.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("The stream descriptor could not be found.",MessageType.Error);
                return;
            }

            EditorGUILayout.LabelField(new GUIContent("Time Range"));
            EditorGUI.BeginDisabledGroup(multipleTimeRanges);

            var abcStart = (float)targetStreamDesc.abcStartTime;
            var abcEnd = (float)targetStreamDesc.abcEndTime;
            var start = (float)streamPlayer.startTime;
            var end = (float)streamPlayer.endTime;
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.MinMaxSlider(" ", ref start, ref end, abcStart, abcEnd);
            if (EditorGUI.EndChangeCheck())
            {
                startTime.doubleValue = start;
                endTime.doubleValue = end;
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(new GUIContent("seconds"));
            EditorGUI.BeginChangeCheck();
            EditorGUIUtility.labelWidth = 35.0f;
            EditorGUI.showMixedValue = startTime.hasMultipleDifferentValues;
            var newStartTime = EditorGUILayout.FloatField(new GUIContent("from", "Start time"), start, GUILayout.MinWidth(80.0f));
            GUILayout.FlexibleSpace();
            EditorGUIUtility.labelWidth = 20.0f;
            EditorGUI.showMixedValue = endTime.hasMultipleDifferentValues;
            var newEndTime = EditorGUILayout.FloatField(new GUIContent("to", "End time"), end, GUILayout.MinWidth(80.0f));
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                startTime.doubleValue = newStartTime;
                endTime.doubleValue = newEndTime;
            }

            EditorGUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();
            EditorGUIUtility.labelWidth = 0.0f;

            GUIStyle style = new GUIStyle();
            style.alignment = TextAnchor.LowerRight;
            if (!endTime.hasMultipleDifferentValues && !startTime.hasMultipleDifferentValues)
            {
                EditorGUILayout.LabelField(new GUIContent((end - start).ToString("0.000") + "s"), style);
            }

            EditorGUILayout.PropertyField(serializedObject.FindProperty("currentTime"), new GUIContent("Time"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("vertexMotionScale"));
            EditorGUILayout.Space();

            m_foldMisc = EditorGUILayout.Foldout(m_foldMisc, "Misc");
            if(m_foldMisc)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(serializedObject.FindProperty("asyncLoad"));
                EditorGUI.indentLevel--;
            }

#if UNITY_2018_3_OR_NEWER
            var prefabStatus = PrefabUtility.GetPrefabInstanceStatus(streamPlayer.gameObject);
            if (prefabStatus == PrefabInstanceStatus.NotAPrefab || prefabStatus == PrefabInstanceStatus.Disconnected)
#else
            if (PrefabUtility.GetPrefabType(streamPlayer.gameObject) == PrefabType.DisconnectedModelPrefabInstance)
#endif
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(16);
                if (GUILayout.Button("Recreate Missing Nodes", GUILayout.Width(180)))
                {
                    streamPlayer.LoadStream(true);
                }
                EditorGUILayout.EndHorizontal();
            }

            this.serializedObject.ApplyModifiedProperties();
        }
        private void DrawEditor()
        {
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_dialogueReader, new GUIContent("Dialog Reader"));
            if (EditorGUI.EndChangeCheck())
            {
                InitDialogueReaderKeys();
            }
            if (m_displayAnimationsAtIndex.Count != m_dialogueAnimations.arraySize || m_currentAnimationIndexes.Count != m_dialogueAnimations.arraySize)
            {
                InitDialogueReaderKeys();
            }
            if (m_dialogueReader.objectReferenceValue != null)
            {
                Color _originalBackgroundColor = GUI.backgroundColor;

                GUILayout.Space(11);
                EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 3), Color.blue);
                GUILayout.Space(11);

                if (m_keys != null)
                {
                    SerializedProperty _prop;
                    SerializedProperty _animationProperty;
                    for (int i = 0; i < m_dialogueAnimations.arraySize; i++)
                    {
                        _prop = m_dialogueAnimations.GetArrayElementAtIndex(i);
                        m_displayAnimationsAtIndex[i] = EditorGUILayout.Foldout(m_displayAnimationsAtIndex[i], "Dialogue Animations called at " + _prop.FindPropertyRelative("m_activationKey").stringValue);
                        if (m_displayAnimationsAtIndex[i])
                        {
                            EditorGUI.BeginChangeCheck();
                            m_currentAnimationIndexes[i] = EditorGUILayout.Popup("Activation Key", m_currentAnimationIndexes[i], m_keys);
                            if (EditorGUI.EndChangeCheck())
                            {
                                _prop.FindPropertyRelative("m_activationKey").stringValue = m_keys[m_currentAnimationIndexes[i]];
                            }
                            GUILayout.Space(10);
                            GUILayout.BeginHorizontal();
                            GUILayout.Label("Triggered Animations");
                            _animationProperty = _prop.FindPropertyRelative("m_animationsTrigger");
                            if (GUILayout.Button(new GUIContent("+"), GUILayout.Width(Screen.width / 8)))
                            {
                                _animationProperty.InsertArrayElementAtIndex(_animationProperty.arraySize);
                            }
                            GUILayout.EndHorizontal();
                            for (int j = 0; j < _animationProperty.arraySize; j++)
                            {
                                SerializedProperty _subProp = _animationProperty.GetArrayElementAtIndex(j);
                                GUILayout.BeginHorizontal();
                                if (GUILayout.Button(new GUIContent("-"), GUILayout.Width(15), GUILayout.Height(12)))
                                {
                                    _animationProperty.DeleteArrayElementAtIndex(j);
                                    continue;
                                }
                                EditorGUILayout.PropertyField(_subProp.FindPropertyRelative("m_triggeredAnimator"), new GUIContent("Animator"));
                                GUILayout.EndHorizontal();
                                _subProp.FindPropertyRelative("m_triggerName").stringValue = EditorGUILayout.TextField(new GUIContent("Trigger Name", "Name of the Trigger used to start the animation"), _subProp.FindPropertyRelative("m_triggerName").stringValue);

                                GUILayout.Space(5);
                            }

                            GUI.backgroundColor = Color.red;
                            if (GUILayout.Button("Remove Animations"))
                            {
                                m_dialogueAnimations.DeleteArrayElementAtIndex(i);
                                m_currentAnimationIndexes.RemoveAt(i);
                                m_displayAnimationsAtIndex.RemoveAt(i);
                            }
                            GUI.backgroundColor = _originalBackgroundColor;
                            EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 3), Color.red);
                        }
                    }
                    GUILayout.Space(5);
                    GUI.backgroundColor = Color.green;
                    if (GUILayout.Button("Add Animations"))
                    {
                        m_dialogueAnimations.InsertArrayElementAtIndex(m_dialogueAnimations.arraySize);
                        m_currentAnimationIndexes.Add(-1);
                        m_displayAnimationsAtIndex.Add(false);
                    }
                    GUI.backgroundColor = _originalBackgroundColor;
                }
            }
            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Allow the constraint to render it's own GUI
        /// </summary>
        /// <returns>Reports if the object's value was changed</returns>
        public override bool OnInspectorGUI()
        {
            bool lIsDirty = false;

            string lNewActionAlias = EditorGUILayout.TextField(new GUIContent("Action Alias", "Action alias that triggers a climb."), ActionAlias, GUILayout.MinWidth(30));

            if (lNewActionAlias != ActionAlias)
            {
                lIsDirty    = true;
                ActionAlias = lNewActionAlias;
            }

            float lNewMinDistance = EditorGUILayout.FloatField(new GUIContent("Min Distance", "Minimum distance inwhich the climb is valid."), MinDistance, GUILayout.MinWidth(30));

            if (lNewMinDistance != MinDistance)
            {
                lIsDirty    = true;
                MinDistance = lNewMinDistance;
            }

            float lNewMaxDistance = EditorGUILayout.FloatField(new GUIContent("Max Distance", "Maximum distance at which the climb is valid."), MaxDistance, GUILayout.MinWidth(30));

            if (lNewMaxDistance != MaxDistance)
            {
                lIsDirty    = true;
                MaxDistance = lNewMaxDistance;
            }

            float lNewMinHeight = EditorGUILayout.FloatField(new GUIContent("Min Height", "Minimum height inwhich the climb is valid."), MinHeight, GUILayout.MinWidth(30));

            if (lNewMinHeight != MinHeight)
            {
                lIsDirty  = true;
                MinHeight = lNewMinHeight;
            }

            float lNewMaxHeight = EditorGUILayout.FloatField(new GUIContent("Max Height", "Maximum height at which the climb is valid."), MaxHeight, GUILayout.MinWidth(30));

            if (lNewMaxHeight != MaxHeight)
            {
                lIsDirty  = true;
                MaxHeight = lNewMaxHeight;
            }

            float lNewHandGrabOffset = EditorGUILayout.FloatField(new GUIContent("Hand Grab Offset", "Offset of the hands from the character's center."), HandGrabOffset, GUILayout.MinWidth(30));

            if (lNewHandGrabOffset != HandGrabOffset)
            {
                lIsDirty       = true;
                HandGrabOffset = lNewHandGrabOffset;
            }

            // Balance layer
            int lNewClimbableLayers = EditorHelper.LayerMaskField(new GUIContent("Climb Layers", "Layers that identies objects that can be climbed."), ClimbableLayers);

            if (lNewClimbableLayers != ClimbableLayers)
            {
                lIsDirty        = true;
                ClimbableLayers = lNewClimbableLayers;
            }

            EditorGUI.indentLevel++;
            mEditorShowOffsets = EditorGUILayout.Foldout(mEditorShowOffsets, new GUIContent("Reach Offsets"));
            if (mEditorShowOffsets)
            {
                Vector3 lNewReachOffset1 = EditorGUILayout.Vector3Field(new GUIContent("Start actor"), _ReachOffset1);
                if (lNewReachOffset1 != _ReachOffset1)
                {
                    lIsDirty      = true;
                    _ReachOffset1 = lNewReachOffset1;
                }

                Vector3 lNewReachOffset2 = EditorGUILayout.Vector3Field(new GUIContent("Start edge"), _ReachOffset2);
                if (lNewReachOffset2 != _ReachOffset2)
                {
                    lIsDirty      = true;
                    _ReachOffset2 = lNewReachOffset2;
                }

                Vector3 lNewReachOffset3 = EditorGUILayout.Vector3Field(new GUIContent("Mid edge"), _ReachOffset3);
                if (lNewReachOffset3 != _ReachOffset3)
                {
                    lIsDirty      = true;
                    _ReachOffset3 = lNewReachOffset3;
                }

                Vector3 lNewReachOffset4 = EditorGUILayout.Vector3Field(new GUIContent("End edge"), _ReachOffset4);
                if (lNewReachOffset4 != _ReachOffset4)
                {
                    lIsDirty      = true;
                    _ReachOffset4 = lNewReachOffset4;
                }
            }
            EditorGUI.indentLevel--;

            return(lIsDirty);
        }
Ejemplo n.º 5
0
    /* void Update()
     * {
     *
     *   if (Input.GetKeyDown(KeyCode.P)) {
     *       Debug.Log("P pressed");
     *   }
     * }*/
    void OnGUI()
    {
        /* if (Event.current != null && Event.current.type == EventType.KeyDown)
         * {
         *   Debug.Log(Event.current.keyCode);
         *   if (Event.current.keyCode==KeyCode.P)
         *   {
         *       Debug.Log("P pressed");
         *       if (player_frozen) {
         *           set_player_controler(false);
         *           player_frozen = false;
         *       } else
         *       {
         *           set_player_controler(true);
         *           player_frozen = true;
         *       }
         *   }
         * }*/

        joueur = GameObject.FindGameObjectWithTag("Player");

        EditorGUILayout.BeginVertical("Button");

        showPosition = EditorGUILayout.Foldout(showPosition, "QUICK SELECT");
        if (showPosition)
        {
            //GUI.backgroundColor = HexToColor(bg_colors[0]);
            // GUILayout.Space(20f);
            //GUILayout.Label("QUICK SELECT", EditorStyles.toolbarButton);
            ScriptableObject   target          = this;
            SerializedObject   so              = new SerializedObject(target);
            SerializedProperty stringsProperty = so.FindProperty("quickselects");
            EditorGUILayout.PropertyField(stringsProperty, true); // True means show children
            so.ApplyModifiedProperties();
            //
            GUI.backgroundColor = HexToColor(bg_colors[0]);
            EditorGUILayout.BeginHorizontal("box");
            if (GUILayout.Button("Player"))
            {
                GameObject cible = GameObject.FindGameObjectWithTag("Player");
                make_selection_active(cible as Object);
                frame_selection();
            }
            if (GUILayout.Button("Camera"))
            {
                GameObject cible = GameObject.FindGameObjectWithTag("MainCamera");
                make_selection_active(cible as Object);
                frame_selection();
                frame_selection();
            }
            EditorGUILayout.EndHorizontal();

            for (int u = 0; u < quickselects.Length; u++)
            {
                if (GUILayout.Button(quickselects[u].name))
                {
                    make_selection_active(quickselects[u] as Object);
                    frame_selection();
                }
            }
        }
        GUI.backgroundColor = Color.white;
        EditorGUILayout.EndVertical();
        ///
        ///
        ///
        //GUILayout.Space(20f);

        EditorGUILayout.BeginVertical("Button");
        showPosition2 = EditorGUILayout.Foldout(showPosition2, "PLAYER CONTROLER");
        if (showPosition2)
        {
            //GUILayout.Label("PLAYER CONTROLER", EditorStyles.boldLabel);
            GUI.backgroundColor = HexToColor(bg_colors[1]);
            EditorGUILayout.BeginHorizontal("box");
            if (GUILayout.Button("DISABLE"))
            {
                set_player_controler(false);
            }
            if (GUILayout.Button("ENABLE"))
            {
                set_player_controler(true);
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndVertical();
        GUI.backgroundColor = Color.white;
        ///
        ///     TELEPORT
        ///
        EditorGUILayout.BeginVertical("Button");
        showPosition3 = EditorGUILayout.Foldout(showPosition3, "TELEPORT");
        if (showPosition3)
        {
            //GUILayout.Label("TELEPORT", EditorStyles.boldLabel);

            ScriptableObject   target2          = this;
            SerializedObject   so2              = new SerializedObject(target2);
            SerializedProperty stringsProperty2 = so2.FindProperty("teleporters");
            EditorGUILayout.PropertyField(stringsProperty2, true); // True means show children
            so2.ApplyModifiedProperties();
            GUI.backgroundColor = HexToColor(bg_colors[2]);
            EditorGUILayout.BeginHorizontal("box");
            int   index_row = 0;
            int   max_row   = 4;
            float btn_width = (Screen.width - 35f) / max_row;

            for (int u = 0; u < teleporters.Length; u++)
            {
                if (GUILayout.Button("TP " + u, GUILayout.Width(btn_width)))
                {
                    joueur.transform.position = (teleporters[u] as GameObject).transform.position;
                }
                index_row++;
                if (index_row == max_row)
                {
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal("box");
                    index_row = 0;
                }
            }
            EditorGUILayout.EndHorizontal();
            //teleporters = EditorGUILayout.ObjectField(teleporters, typeof(Object), true);
        }
        EditorGUILayout.EndVertical();
    }
    void EditorDataGUI()
    {
        m_isEditorFold = EditorGUILayout.Foldout(m_isEditorFold, "编辑数据");
        EditorGUI.indentLevel++;

        if (m_isEditorFold)
        {
            List <string> keys = m_currentData.TableKeys;
            m_EditorPos = EditorGUILayout.BeginScrollView(m_EditorPos, GUILayout.ExpandHeight(false));
            for (int i = 0; i < keys.Count; i++)
            {
                string    key           = keys[i];
                FieldType type          = m_currentData.GetFieldType(key);
                int       EnumTypeIndex = EditorTool.GetAllEnumTypeIndex(m_currentData.GetEnumType(key));

                if (i == 0)
                {
                    EditorGUILayout.LabelField("<主键>字段名", key);
                    EditorGUILayout.LabelField("字段类型", m_currentData.GetFieldType(keys[i]).ToString());
                }
                else
                {
                    EditorGUILayout.BeginHorizontal();

                    EditorGUILayout.LabelField("字段名", key);

                    if (GUILayout.Button("删除字段"))
                    {
                        if (EditorUtility.DisplayDialog("警告", "确定要删除该字段吗?", "是", "取消"))
                        {
                            DeleteField(m_currentData, key);
                            continue;
                        }
                    }

                    EditorGUILayout.EndHorizontal();

                    bool isNewType = false;

                    m_editorNoteContent = EditorGUILayout.TextField("注释", m_currentData.GetNote(key));
                    m_currentData.SetNote(key, m_editorNoteContent);

                    m_editorNewType = (FieldType)EditorGUILayout.EnumPopup("字段类型", type);

                    if (m_editorNewType == FieldType.Enum)
                    {
                        m_editorNewEnumIndex = EditorGUILayout.Popup("枚举类型", EnumTypeIndex, EditorTool.GetAllEnumType());

                        if (EnumTypeIndex != m_editorNewEnumIndex)
                        {
                            isNewType = true;
                        }
                    }

                    if (type != m_editorNewType)
                    {
                        isNewType = true;
                    }

                    if (isNewType)
                    {
                        //弹出警告并重置数据
                        if (EditorUtility.DisplayDialog("警告", "改变字段类型会重置该字段的所有数据和默认值\n是否继续?", "是", "取消"))
                        {
                            m_currentData.SetFieldType(key, m_editorNewType, EditorTool.GetAllEnumType()[m_editorNewEnumIndex]);
                            ResetDataField(m_currentData, key, m_editorNewType, EditorTool.GetAllEnumType()[m_editorNewEnumIndex]);

                            type          = m_editorNewType;
                            EnumTypeIndex = m_editorNewEnumIndex;
                            content       = new SingleData();
                        }
                    }

                    string newContent;
                    if (type == FieldType.Enum)
                    {
                        newContent = EditorUtilGUI.FieldGUI_Type(type, EditorTool.GetAllEnumType()[EnumTypeIndex], m_currentData.GetDefault(key), "默认值");
                    }
                    else
                    {
                        newContent = EditorUtilGUI.FieldGUI_Type(type, null, m_currentData.GetDefault(key), "默认值");
                    }

                    m_currentData.SetDefault(key, newContent);
                }

                EditorGUILayout.Space();
            }

            EditorGUILayout.EndScrollView();

            AddFieldGUI();
        }
    }
Ejemplo n.º 7
0
    public override void OnInspectorGUI()
    {
        Grid myScript = (Grid)target;

        EditorGUILayout.Space();
        GUIStyle labelStyle = EditorStyles.label;

        labelStyle.fontStyle = FontStyle.Bold;
        int temp = labelStyle.fontSize;

        labelStyle.fontSize = 15;


        labelStyle.fontSize  = temp;
        labelStyle.fontStyle = FontStyle.Normal;

        myScript.gridWorldSize       = EditorGUILayout.Vector2Field("Grid size: ", myScript.gridWorldSize);
        myScript.nodeRadius          = EditorGUILayout.FloatField("Node radius: ", myScript.nodeRadius);
        myScript.nearestNodeDistance = EditorGUILayout.FloatField("Nearest node distance: ", myScript.nearestNodeDistance);
        myScript.collisionRadius     = EditorGUILayout.Slider("Collision radius: ", myScript.collisionRadius, 0, 3);
        EditorGUILayout.Space();
        GUIStyle  style         = EditorStyles.foldout;
        FontStyle previousStyle = style.fontStyle;

        style.fontStyle = FontStyle.Bold;

        layers = EditorGUILayout.Foldout(layers, "Layers", style);
        if (layers)
        {
            //myScript.unwalkableMask = LayerMaskField("Unwalkable layers:", myScript.unwalkableMask);
            SerializedObject   serializedObject1 = new SerializedObject(target);
            SerializedProperty property2         = serializedObject1.FindProperty("unwalkableMask");
            serializedObject1.Update();
            EditorGUILayout.PropertyField(property2, true);
            serializedObject1.ApplyModifiedProperties();



            SerializedObject   serializedObject = new SerializedObject(target);
            SerializedProperty property         = serializedObject.FindProperty("walkableRegions");
            serializedObject.Update();
            EditorGUILayout.PropertyField(property, true);
            serializedObject.ApplyModifiedProperties();
        }

        EditorGUILayout.Space();

        advanced = EditorGUILayout.Foldout(advanced, "Advanced", style);
        //style.fontStyle = previousStyle;
        if (advanced)
        {
            //EditorGUILayout.LabelField("Inspector", EditorStyles.boldLabel);

            myScript.options             = (Grid.Connections)EditorGUILayout.EnumPopup("Connections", myScript.options);
            myScript.heuristicMultiplier = EditorGUILayout.Slider("Heuristic estimation: ", myScript.heuristicMultiplier, 0, 3);
            //myScript.heuristicMethod = (Grid.Heuristics)EditorGUILayout.EnumPopup("Heuristics", myScript.heuristicMethod);
            myScript.showGrid            = EditorGUILayout.Toggle("Show Grid", myScript.showGrid);
            myScript.showPathSearchDebug = EditorGUILayout.Toggle("Show search debug", myScript.showPathSearchDebug);
            myScript.useThreading        = EditorGUILayout.Toggle("Use threading", myScript.useThreading);
        }



        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();


        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        if (GUILayout.Button("Test grid", GUILayout.Width(300), GUILayout.Height(30)))
        {
            myScript.CreateGrid();
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();


        EditorUtility.SetDirty(myScript);
    }
Ejemplo n.º 8
0
        private void OnGUI()
        {
            string selectedPath = AssetDatabase.GetAssetPath(UnityEditor.Selection.activeObject);

            if (string.IsNullOrEmpty(selectedPath))
            {
                return;
            }

            // Standard spacing to mimic Unity's Inspector header
            GUILayout.Space(2);

            Rect rect;

            GUILayout.BeginHorizontal("In BigTitle");
            GUILayout.Label(AssetDatabase.GetCachedIcon(selectedPath), GUILayout.Width(36), GUILayout.Height(36));
            GUILayout.BeginVertical();
            GUILayout.Label(Path.GetFileName(selectedPath), TitleStyle);
            // Display directory (without "Assets/" prefix)
            GUILayout.Label(Regex.Match(Path.GetDirectoryName(selectedPath), "(\\\\.*)$").Value);
            rect = GUILayoutUtility.GetLastRect();
            GUILayout.EndVertical();
            GUILayout.Space(44);
            GUILayout.EndHorizontal();

            if (Directory.Exists(selectedPath))
            {
                return;
            }

            AssetInfo selectedAssetInfo = ProjectCurator.GetAsset(selectedPath);

            if (selectedAssetInfo == null)
            {
                bool rebuildClicked = HelpBoxWithButton(new GUIContent("You must rebuild database to obtain information on this asset", EditorGUIUtility.IconContent("console.warnicon").image), new GUIContent("Rebuild Database"));
                if (rebuildClicked)
                {
                    ProjectCurator.RebuildDatabase();
                }
                return;
            }

            var content = new GUIContent(selectedAssetInfo.IsIncludedInBuild ? ProjectIcons.LinkBlue : ProjectIcons.LinkBlack, selectedAssetInfo.IncludedStatus.ToString());

            GUI.Label(new Rect(position.width - 20, rect.y + 1, 16, 16), content);

            scroll = GUILayout.BeginScrollView(scroll);

            dependenciesOpen = EditorGUILayout.Foldout(dependenciesOpen, $"Dependencies ({selectedAssetInfo.dependencies.Count})");
            if (dependenciesOpen)
            {
                foreach (var dependency in selectedAssetInfo.dependencies)
                {
                    if (GUILayout.Button(Path.GetFileName(dependency), ItemStyle))
                    {
                        UnityEditor.Selection.activeObject = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(dependency);
                    }
                    rect = GUILayoutUtility.GetLastRect();
                    GUI.DrawTexture(new Rect(rect.x - 16, rect.y, rect.height, rect.height), AssetDatabase.GetCachedIcon(dependency));
                    AssetInfo depInfo = ProjectCurator.GetAsset(dependency);
                    content = new GUIContent(depInfo.IsIncludedInBuild ? ProjectIcons.LinkBlue : ProjectIcons.LinkBlack, depInfo.IncludedStatus.ToString());
                    GUI.Label(new Rect(rect.width + rect.x - 20, rect.y + 1, 16, 16), content);
                }
            }

            GUILayout.Space(6);

            referencesOpen = EditorGUILayout.Foldout(referencesOpen, $"Referencers ({selectedAssetInfo.referencers.Count})");
            if (referencesOpen)
            {
                foreach (var referencer in selectedAssetInfo.referencers)
                {
                    if (GUILayout.Button(Path.GetFileName(referencer), ItemStyle))
                    {
                        UnityEditor.Selection.activeObject = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(referencer);
                    }
                    rect = GUILayoutUtility.GetLastRect();
                    GUI.DrawTexture(new Rect(rect.x - 16, rect.y, rect.height, rect.height), AssetDatabase.GetCachedIcon(referencer));
                    AssetInfo refInfo = ProjectCurator.GetAsset(referencer);
                    content = new GUIContent(refInfo.IsIncludedInBuild ? ProjectIcons.LinkBlue : ProjectIcons.LinkBlack, refInfo.IncludedStatus.ToString());
                    GUI.Label(new Rect(rect.width + rect.x - 20, rect.y + 1, 16, 16), content);
                }
            }

            GUILayout.Space(5);

            GUILayout.EndScrollView();

            if (!selectedAssetInfo.IsIncludedInBuild)
            {
                bool deleteClicked = HelpBoxWithButton(new GUIContent("This asset is not referenced and never used. Would you like to delete it ?", EditorGUIUtility.IconContent("console.warnicon").image), new GUIContent("Delete Asset"));
                if (deleteClicked)
                {
                    File.Delete(selectedPath);
                    AssetDatabase.Refresh();
                    ProjectCurator.RemoveAssetFromDatabase(selectedPath);
                }
            }
        }
Ejemplo n.º 9
0
        private void NamedItemEditor(SerializedProperty data, string type, string property, string caption, ref string errorMessage, ref bool foldout, ref string newName)
        {
            SerializedProperty items = data.FindPropertyRelative(property);

            items.isExpanded = EditorGUILayout.Foldout(items.isExpanded, caption);
            //bool up, down;
            mAllNames.Clear();
            int size = items.arraySize;

            if (Event.current.type == EventType.Layout)
            {
                DoOperations(items, size, type);
            }
            size = items.arraySize;
            if (items.isExpanded)
            {
                EditorGUI.indentLevel++;
                for (int i = 0; i < size; i++)
                {
                    SerializedProperty entry = items.GetArrayElementAtIndex(i);
                    if (entry == null)
                    {
                        continue;
                    }
                    SerializedProperty nameProp = entry.FindPropertyRelative("Name");
                    string             name     = null;
                    if (nameProp == null)
                    {
                        name = entry.stringValue;
                    }
                    else
                    {
                        name = nameProp.stringValue;
                    }
                    mAllNames.Add(name);
                    EditorGUILayout.BeginHorizontal();
                    bool toogle = false;
                    if (nameProp != null)
                    {
                        toogle = entry.isExpanded = EditorGUILayout.Foldout(entry.isExpanded, name);
                    }
                    else
                    {
                        toogle = false;
                        EditorGUILayout.LabelField(name);
                    }
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("..."))
                    {
                        DoRosJsonMessage(type, name);
                    }
                    EditorGUILayout.EndHorizontal();
                    if (toogle)
                    {
                        EditorGUI.indentLevel++;
                        if (nameProp != null)
                        {
                            SerializedProperty end = entry.GetEndProperty(true);
                            entry.Next(true);
                            if (SerializedProperty.EqualContents(entry, end) == false)
                            {
                                do
                                {
                                    if (entry.name != "Name")
                                    {
                                        if (target is CanvasRadarChart)
                                        {
                                            if (NonCanvas.Contains(entry.name))
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            if (entry.name == "LineHover" || entry.name == "PointHover")
                                            {
                                                continue;
                                            }
                                        }
                                        EditorGUILayout.PropertyField(entry, true);
                                    }
                                }while (entry.Next(entry.name == "Materials") && SerializedProperty.EqualContents(entry, end) == false);
                            }
                        }
                        EditorGUI.indentLevel--;
                    }
                }

                if (errorMessage != null)
                {
                    EditorGUILayout.LabelField(errorMessage, mRedStyle);
                }
                EditorGUILayout.LabelField(string.Format("Add new {0} :", type));
                //Rect indentAdd = EditorGUI.IndentedRect(new Rect(0f, 0f, 1000f, 1000f));
                EditorGUILayout.BeginHorizontal();
                newName = EditorGUILayout.TextField(newName);
                //GUILayout.Space(indentAdd.xMin);
                if (GUILayout.Button("Add"))
                {
                    bool error = false;
                    if (newName.Trim().Length == 0)
                    {
                        errorMessage = "Name can't be empty";
                        error        = true;
                    }
                    else if (ChartEditorCommon.IsAlphaNum(newName) == false)
                    {
                        errorMessage = "Name conatins invalid characters";
                        error        = true;
                    }
                    else if (mAllNames.Contains(newName))
                    {
                        errorMessage = string.Format("A {0} named {1} already exists in this chart", type, newName);
                        error        = true;
                    }
                    if (error == false)
                    {
                        errorMessage = null;
                        items.InsertArrayElementAtIndex(size);
                        SerializedProperty newItem     = items.GetArrayElementAtIndex(size);
                        SerializedProperty newItemName = newItem.FindPropertyRelative("Name");
                        if (newItemName == null)
                        {
                            newItem.stringValue = newName;
                        }
                        else
                        {
                            newItemName.stringValue = newName;
                        }
                        newName = "";
                        UpdateWindow();
                    }
                }
                EditorGUILayout.EndHorizontal();
                EditorGUI.indentLevel--;
            }
            else
            {
                errorMessage = null;
            }
            UpdateWindow();
        }
Ejemplo n.º 10
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        FindProperties(properties); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly
        Material material = materialEditor.target as Material;

        string[] keyWords = material.shaderKeywords;

        EditorGUI.BeginChangeCheck();

        // Render default properties
        if (_debugMode)
        {
            EditorGUILayout.BeginVertical("Box");
            base.OnGUI(materialEditor, properties);
            EditorGUILayout.EndVertical();
        }
        else
        {
            //Button collapse-expand
            if (GUILayout.Button("Collapse-Expand"))
            {
                _showBasePattern = _showCenterGrid = _showCenterLine = _showEdge = _showText = (_showBase = !_showBase);
            }

            EditorGUILayout.Separator();

            //World position
            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("World Position UV's");
            EditorGUILayout.Separator();

            _worldPos = keyWords.Contains("WPOS_ON");
            _worldPos = EditorGUILayout.Toggle("Enable", _worldPos);

            if (EditorGUI.EndChangeCheck())
            {
                var keywords = new List <string> {
                    _worldPos ? "WPOS_ON" : "WPOS_OFF"
                };
                material.shaderKeywords = keywords.ToArray();
                EditorUtility.SetDirty(material);
            }

            if (_worldPos)
            {
                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("XY Tiling     -      ZW Offset");
                materialEditor.VectorProperty(_WolrdBpattTiling, "Base Pattern");
                materialEditor.VectorProperty(_WolrdCgridTiling, "Center Grid");
                materialEditor.VectorProperty(_WolrdClineTiling, "Center Line");
                materialEditor.VectorProperty(_WolrdEdgeTiling, "Edge");
                materialEditor.VectorProperty(_WolrdTextTiling, "Text");
            }

            EditorGUILayout.EndVertical();

            //BASE
            EditorGUILayout.BeginVertical("Box");
            _showBase = EditorGUILayout.Foldout(_showBase, "Base properties");

            if (_showBase)
            {
                EditorGUILayout.Separator();
                materialEditor.ColorProperty(_BaseColor, "Base Color");
                EditorGUILayout.Separator();

                materialEditor.FloatProperty(_TilingX, "Tile X");
                materialEditor.FloatProperty(_TilingY, "Tile Y");
                EditorGUILayout.Separator();



                EditorGUILayout.Separator();
                materialEditor.RangeProperty(_GlobalMet, "Global Metallic Mult");
                materialEditor.RangeProperty(_GlobalSmo, "Global Smoothness Mult");
                materialEditor.RangeProperty(_GlobalEmi, "Global Emission Mult");

                EditorGUILayout.Separator();
            }

            EditorGUILayout.EndVertical();

            //BASE PATTERN
            EditorGUILayout.BeginVertical("Box");
            _showBasePattern = EditorGUILayout.Foldout(_showBasePattern, "Base Pattern properties");

            if (_showBasePattern)
            {
                EditorGUILayout.Separator();

                materialEditor.TextureProperty(_BasePatternTex, "Texture", !_worldPos);
                materialEditor.ColorProperty(_BasePatternColor, "Color");
                EditorGUILayout.Separator();

                materialEditor.RangeProperty(_BasePatternMet, "Metallic");
                materialEditor.RangeProperty(_BasePatternSmo, "Smoothness");
                materialEditor.RangeProperty(_BasePatternEmi, "Emission");
                EditorGUILayout.Separator();
            }

            EditorGUILayout.EndVertical();

            //CENTER GRID
            EditorGUILayout.BeginVertical("Box");
            _showCenterGrid = EditorGUILayout.Foldout(_showCenterGrid, "Center Grid properties");

            if (_showCenterGrid)
            {
                EditorGUILayout.Separator();

                materialEditor.TextureProperty(_CenterGridTex, "Texture", !_worldPos);
                materialEditor.ColorProperty(_CenterGridColor, "Color");
                EditorGUILayout.Separator();

                materialEditor.RangeProperty(_CenterGridMet, "Metallic");
                materialEditor.RangeProperty(_CenterGridSmo, "Smoothness");
                materialEditor.RangeProperty(_CenterGridEmi, "Emission");
                EditorGUILayout.Separator();
            }

            EditorGUILayout.EndVertical();

            //CENTER LINE
            EditorGUILayout.BeginVertical("Box");
            _showCenterLine = EditorGUILayout.Foldout(_showCenterLine, "Center Line properties");

            if (_showCenterLine)
            {
                EditorGUILayout.Separator();

                materialEditor.TextureProperty(_CenterLineTex, "Texture", !_worldPos);
                materialEditor.ColorProperty(_CenterLineColor, "Color");
                EditorGUILayout.Separator();

                materialEditor.RangeProperty(_CenterLineMet, "Metallic");
                materialEditor.RangeProperty(_CenterLineSmo, "Smoothness");
                materialEditor.RangeProperty(_CenterLineEmi, "Emission");
                EditorGUILayout.Separator();
            }

            EditorGUILayout.EndVertical();

            //EDGE
            EditorGUILayout.BeginVertical("Box");
            _showEdge = EditorGUILayout.Foldout(_showEdge, "Edge properties");

            if (_showEdge)
            {
                EditorGUILayout.Separator();

                materialEditor.TextureProperty(_EdgeTex, "Texture", !_worldPos);
                materialEditor.ColorProperty(_EdgeColor, "Color");
                EditorGUILayout.Separator();

                materialEditor.RangeProperty(_EdgeMet, "Metallic");
                materialEditor.RangeProperty(_EdgeSmo, "Smoothness");
                materialEditor.RangeProperty(_EdgeEmi, "Emission");
                EditorGUILayout.Separator();
            }

            EditorGUILayout.EndVertical();

            //EDGE
            EditorGUILayout.BeginVertical("Box");
            _showText = EditorGUILayout.Foldout(_showText, "Text properties");

            if (_showText)
            {
                EditorGUILayout.Separator();

                materialEditor.TextureProperty(_TextTex, "Texture", !_worldPos);
                materialEditor.ColorProperty(_TextColor, "Color");
                EditorGUILayout.Separator();

                materialEditor.RangeProperty(_TextMet, "Metallic");
                materialEditor.RangeProperty(_TextSmo, "Smoothness");
                materialEditor.RangeProperty(_TextEmi, "Emission");
                EditorGUILayout.Separator();
            }

            EditorGUILayout.EndVertical();
        }// End else

        EditorGUILayout.BeginVertical("Box");
        _debugMode = EditorGUILayout.Toggle("Debug Mode", _debugMode);
        EditorGUILayout.EndVertical();
    }
Ejemplo n.º 11
0
    void OnGUI()
    {
        GUILayout.Space(50);
        int select_index = select;

        select_index = GUILayout.Toolbar(select_index, labls, GUILayout.Height(50));//GUILayout.Width(200),
        select       = select_index;

        switch (select)
        {
        case 0:    //创建地图
            #region 创建地图
            GUILayout.Space(20);
            cell_root = EditorGUILayout.ObjectField("Cell节点对象", cell_root, typeof(GameObject), true) as GameObject;
            cell      = EditorGUILayout.ObjectField("Cell", cell, typeof(GameObject), true) as GameObject;
            size      = EditorGUILayout.Vector2IntField("地图规格", size);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("生成新地图面", GUILayout.ExpandWidth(true)))
            {
                while (cell_root.transform.childCount > 0)
                {
                    DestroyImmediate(cell_root.transform.GetChild(0).gameObject);
                }
                cell_root.GetComponent <UIGrid>().maxPerLine = size.x;
                int num = size.x * size.y;
                for (int i = 0; i < num; i++)
                {
                    GameObject obj = GameObject.Instantiate(cell);
                    obj.name             = cell.name;
                    obj.transform.parent = cell_root.transform;
                }
                cell_root.GetComponent <UIGrid>().Reposition();
            }
            //GUILayout.Space(120);
            if (GUILayout.Button("删除地图面(结束配置后使用)", GUILayout.ExpandWidth(true)))
            {
                while (cell_root.transform.childCount > 0)
                {
                    DestroyImmediate(cell_root.transform.GetChild(0).gameObject);
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(10);
            #endregion
            break;

        case 1:    //编辑地图
            #region 编辑地图
            GUILayout.Space(10);
            foldoutType = EditorGUILayout.Foldout(foldoutType, "单体组件(1*1单位)");
            if (foldoutType)
            {
                obj_0 = EditorGUILayout.ObjectField("obj_0", obj_0, typeof(GameObject), true) as GameObject;
                obj_1 = EditorGUILayout.ObjectField("obj_1", obj_1, typeof(GameObject), true) as GameObject;
                obj_2 = EditorGUILayout.ObjectField("obj_2", obj_2, typeof(GameObject), true) as GameObject;
                obj_3 = EditorGUILayout.ObjectField("obj_3", obj_3, typeof(GameObject), true) as GameObject;
                obj_4 = EditorGUILayout.ObjectField("obj_4", obj_4, typeof(GameObject), true) as GameObject;
            }
            GUILayout.Space(10);
            index = EditorGUILayout.Popup("配置类型选择", index, options);
            GUILayout.Label("    当前配置 :" + options[index]);
            GUILayout.Space(10);
            Sprite sprite = null;
            switch (index)
            {
            case 0:
                if (obj_0)
                {
                    sprite = obj_0.GetComponent <SpriteRenderer>().sprite;
                }
                break;

            case 1:
                if (obj_1)
                {
                    sprite = obj_1.GetComponent <SpriteRenderer>().sprite;
                }
                break;

            case 2:
                if (obj_2)
                {
                    sprite = obj_2.GetComponent <SpriteRenderer>().sprite;
                }
                break;

            case 3:
                if (obj_3)
                {
                    sprite = obj_3.GetComponent <SpriteRenderer>().sprite;
                }
                break;

            case 4:
                if (obj_4)
                {
                    sprite = obj_4.GetComponent <SpriteRenderer>().sprite;
                }
                break;
            }
            Sprite_ = EditorGUILayout.ObjectField("预览", sprite, typeof(Sprite), true) as Sprite;

            root       = GameObject.Find("Root");
            transforms = Selection.transforms;
            GUILayout.Space(10);
            set_model_index = EditorGUILayout.Popup("配置模式选择", set_model_index, set_model);
            if (set_model_index == 1)
            {
                GUILayout.Space(10);
                if (GUILayout.Button("Clone"))
                {
                    int i = 0;
                    foreach (Transform T in transforms)
                    {
                        GameObject pre = null;
                        switch (index.ToString())
                        {
                        case "0":
                            pre = obj_0;
                            break;

                        case "1":
                            pre = obj_1;
                            break;

                        case "2":
                            pre = obj_2;
                            break;

                        case "3":
                            pre = obj_3;
                            break;

                        case "4":
                            pre = obj_4;
                            break;
                        }
                        GameObject obj = GameObject.Instantiate(pre);
                        obj.name               = index.ToString();
                        obj.transform.parent   = root.transform;
                        obj.transform.position = T.position;
                        obj.transform.tag      = "Clone_cell";
                        i++;
                    }
                    Debug.Log("Clone Done ,All number is [" + i + "]");
                }
            }
            GUILayout.Space(10);
            //if (GUILayout.Button("当前地图信息"))
            //{
            //}
            //GUILayout.Space(10);
            #endregion
            break;

        case 2:    //删除地图
            #region  除地图
            set_model_index = EditorGUILayout.Popup("配置模式选择", set_model_index, set_model);
            if (GUILayout.Button("Delete All"))
            {
                while (root.transform.childCount > 0)
                {
                    DestroyImmediate(root.transform.GetChild(0).gameObject);
                }
            }
            #endregion
            break;

        case 3:    //关于
            GUILayout.Label("DK_shuai");
            Sprite_to_b   = EditorGUILayout.ObjectField(" ", Sprite_to_b, typeof(Sprite), true) as Sprite;
            Sprite_to_b_1 = EditorGUILayout.ObjectField(" ", Sprite_to_b_1, typeof(Sprite), true) as Sprite;
            Sprite_to_b_2 = EditorGUILayout.ObjectField(" ", Sprite_to_b_2, typeof(Sprite), true) as Sprite;
            GUILayout.Space(10);
            break;
        }

        //绘制当前正在编辑的场景
        GUILayout.Space(10);
        GUI.skin.label.fontSize  = 12;
        GUI.skin.label.alignment = TextAnchor.UpperLeft;
        GUILayout.Label("当前操作场景名称:" + EditorSceneManager.GetActiveScene().name);
        #region
        ////绘制当前时间
        //GUILayout.Space(10);
        //GUILayout.Label("Time:" + System.DateTime.Now);

        ////绘制对象
        //GUILayout.Space(10);
        //buggyGameObject = (GameObject)EditorGUILayout.ObjectField("Buggy Game Object", buggyGameObject, typeof(GameObject), true);

        ////绘制描述文本区域
        //GUILayout.Space(10);
        //GUILayout.BeginHorizontal();
        //GUILayout.Label("Description", GUILayout.MaxWidth(80));
        //description = EditorGUILayout.TextArea(description, GUILayout.MaxHeight(75));
        //GUILayout.EndHorizontal();

        //EditorGUILayout.Space();

        ////添加名为"Save Bug"按钮,用于调用SaveBug()函数
        //if (GUILayout.Button("Save Bug"))
        //{
        //    SaveBug();
        //}

        ////添加名为"Save Bug with Screenshot"按钮,用于调用SaveBugWithScreenshot() 函数
        //if (GUILayout.Button("Save Bug With Screenshot"))
        //{
        //    SaveBugWithScreenshot();
        //}
        #endregion
    }
Ejemplo n.º 12
0
        public override void OnInspectorGUI()
        {
            ////TODO: cache properties

            EditorGUI.BeginChangeCheck();

            // Action config section.
            EditorGUI.BeginChangeCheck();
            var actionsProperty = serializedObject.FindProperty("m_Actions");

            EditorGUILayout.PropertyField(actionsProperty);
            if (EditorGUI.EndChangeCheck() || !m_ActionAssetInitialized)
            {
                OnActionAssetChange();
            }
            ++EditorGUI.indentLevel;
            if (m_ControlSchemeOptions != null && m_ControlSchemeOptions.Length > 1) // Don't show if <Any> is the only option.
            {
                // Default control scheme picker.

                var selected = EditorGUILayout.Popup(m_DefaultControlSchemeText, m_SelectedDefaultControlScheme,
                                                     m_ControlSchemeOptions);
                if (selected != m_SelectedDefaultControlScheme)
                {
                    var defaultControlSchemeProperty = serializedObject.FindProperty("m_DefaultControlScheme");
                    if (selected == 0)
                    {
                        defaultControlSchemeProperty.stringValue = null;
                    }
                    else
                    {
                        defaultControlSchemeProperty.stringValue =
                            m_ControlSchemeOptions[selected].text;
                    }
                    m_SelectedDefaultControlScheme = selected;
                }

                var neverAutoSwitchProperty = serializedObject.FindProperty("m_NeverAutoSwitchControlSchemes");
                var neverAutoSwitchValueOld = neverAutoSwitchProperty.boolValue;
                var neverAutoSwitchValueNew = !EditorGUILayout.Toggle(m_AutoSwitchText, !neverAutoSwitchValueOld);
                if (neverAutoSwitchValueOld != neverAutoSwitchValueNew)
                {
                    neverAutoSwitchProperty.boolValue = neverAutoSwitchValueNew;
                    serializedObject.ApplyModifiedProperties();
                }
            }
            if (m_ActionMapOptions != null && m_ActionMapOptions.Length > 0)
            {
                // Default action map picker.

                var selected = EditorGUILayout.Popup(m_DefaultActionMapText, m_SelectedDefaultActionMap,
                                                     m_ActionMapOptions);
                if (selected != m_SelectedDefaultActionMap)
                {
                    var defaultActionMapProperty = serializedObject.FindProperty("m_DefaultActionMap");
                    if (selected == 0)
                    {
                        defaultActionMapProperty.stringValue = null;
                    }
                    else
                    {
                        // Use ID rather than name.
                        var asset     = (InputActionAsset)serializedObject.FindProperty("m_Actions").objectReferenceValue;
                        var actionMap = asset.FindActionMap(m_ActionMapOptions[selected].text);
                        if (actionMap != null)
                        {
                            defaultActionMapProperty.stringValue = actionMap.id.ToString();
                        }
                    }
                    m_SelectedDefaultActionMap = selected;
                }
            }
            --EditorGUI.indentLevel;
            DoHelpCreateAssetUI();

            // UI config section.
            var uiModuleProperty = serializedObject.FindProperty("m_UIInputModule");

            if (m_UIPropertyText == null)
            {
                m_UIPropertyText = EditorGUIUtility.TrTextContent("UI Input Module", uiModuleProperty.tooltip);
            }
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(uiModuleProperty, m_UIPropertyText);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            if (uiModuleProperty.objectReferenceValue != null)
            {
                var uiModule = uiModuleProperty.objectReferenceValue as InputSystemUIInputModule;
                if (actionsProperty.objectReferenceValue != null && uiModule.actionsAsset != actionsProperty.objectReferenceValue)
                {
                    EditorGUILayout.HelpBox("The referenced InputSystemUIInputModule is configured using differnet input actions then this PlayerInput. They should match if you want to synchronize PlayerInput actions to the UI input.", MessageType.Warning);
                    if (GUILayout.Button(m_FixInputModuleText))
                    {
                        InputSystemUIInputModuleEditor.ReassignActions(uiModule, actionsProperty.objectReferenceValue as InputActionAsset);
                    }
                }
            }

            // Camera section.
            var cameraProperty = serializedObject.FindProperty("m_Camera");

            if (m_CameraPropertyText == null)
            {
                m_CameraPropertyText = EditorGUIUtility.TrTextContent("Camera", cameraProperty.tooltip);
            }
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(cameraProperty, m_CameraPropertyText);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            // Notifications/event section.
            EditorGUI.BeginChangeCheck();
            var notificationsProperty = serializedObject.FindProperty("m_NotificationBehavior");

            EditorGUILayout.PropertyField(notificationsProperty, m_NotificationBehaviorText);
            if (EditorGUI.EndChangeCheck() || !m_NotificationBehaviorInitialized)
            {
                OnNotificationBehaviorChange();
            }
            switch ((PlayerNotifications)notificationsProperty.intValue)
            {
            case PlayerNotifications.SendMessages:
            case PlayerNotifications.BroadcastMessages:
                Debug.Assert(m_SendMessagesHelpText != null);
                EditorGUILayout.HelpBox(m_SendMessagesHelpText);
                break;

            case PlayerNotifications.InvokeUnityEvents:
                m_EventsGroupUnfolded = EditorGUILayout.Foldout(m_EventsGroupUnfolded, m_EventsGroupText);
                if (m_EventsGroupUnfolded)
                {
                    // Action events. Group by action map.
                    if (m_ActionNames != null)
                    {
                        using (new EditorGUI.IndentLevelScope())
                        {
                            var actionEvents = serializedObject.FindProperty("m_ActionEvents");
                            for (var n = 0; n < m_NumActionMaps; ++n)
                            {
                                m_ActionMapEventsUnfolded[n] = EditorGUILayout.Foldout(m_ActionMapEventsUnfolded[n],
                                                                                       m_ActionMapNames[n]);
                                using (new EditorGUI.IndentLevelScope())
                                {
                                    if (m_ActionMapEventsUnfolded[n])
                                    {
                                        for (var i = 0; i < m_ActionNames.Length; ++i)
                                        {
                                            if (m_ActionMapIndices[i] != n)
                                            {
                                                continue;
                                            }

                                            EditorGUILayout.PropertyField(actionEvents.GetArrayElementAtIndex(i), m_ActionNames[i]);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    // Misc events.
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("m_DeviceLostEvent"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("m_DeviceRegainedEvent"));
                }
                break;
            }

            // Miscellaneous buttons.
            DoUtilityButtonsUI();

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            // Debug UI.
            if (EditorApplication.isPlaying)
            {
                DoDebugUI();
            }
        }
Ejemplo n.º 13
0
        public override void OnInspectorGUI()
        {
            if (target is UIObject obj && !obj.useController)
            {
                if (targets.Length == 1)
                {
                    Animator animator = (target as UIObject).GetComponent <Animator>();
                    if (animator == null || animator.runtimeAnimatorController == null)
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField("必须有Animator和AnimatorController才能使用Controller");
                        if (GUILayout.Button("创建Controller"))
                        {
                            if (animator == null)
                            {
                                animator = (target as UIObject).gameObject.AddComponent <Animator>();
                            }
                            string controllerPath = EditorUtility.SaveFilePanel("保存动画控制器", Application.dataPath, (target as UIObject).gameObject.name + "_Controller", "controller");
                            controllerPath = controllerPath.Replace(Environment.CurrentDirectory.Replace('\\', '/') + "/", string.Empty);
                            AnimatorController controller = AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
                            animator.runtimeAnimatorController = controller;
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    else if (animator.runtimeAnimatorController is AnimatorController controller)
                    {
                        AnimatorControllerLayer removeLayer  = null;
                        AnimatorControllerLayer rebuildLayer = null;
                        string controllerPath = AssetDatabase.GetAssetPath(controller);
                        string controllerDir  = Path.GetDirectoryName(controllerPath);
                        foreach (AnimatorControllerLayer layer in controller.layers)
                        {
                            Match m = Regex.Match(layer.name, @"(?<name>\w+)Controller");
                            if (m.Success)
                            {
                                string controllerName = m.Groups["name"].Value;
                                if (!controllerFoldDic.ContainsKey(controllerName))
                                {
                                    controllerFoldDic.Add(controllerName, false);
                                }
                                layer.defaultWeight = 1;
                                EditorGUILayout.BeginHorizontal();
                                //展开Controller
                                controllerFoldDic[controllerName] = EditorGUILayout.Foldout(controllerFoldDic[controllerName], controllerName);
                                if (EditorApplication.isPlaying && targets.Length == 1)
                                {
                                    //Controller当前状态
                                    string currentStateName = (target as UIObject).getController(controllerName, layer.stateMachine.states.Select(s => s.state.name).ToArray());
                                    EditorGUILayout.LabelField(currentStateName, GUILayout.Width(100));
                                    // Debug.Log(currentStateName, target);
                                }
                                else if (layer.stateMachine != null && layer.stateMachine.states.Length > 0)
                                {
                                    SerializedProperty initStatesProp = serializedObject.FindProperty("_initStates");
                                    int propIndex = -1;
                                    for (int i = 0; i < initStatesProp.arraySize; i++)
                                    {
                                        if (initStatesProp.GetArrayElementAtIndex(i).stringValue.Contains(controllerName))
                                        {
                                            propIndex = i;
                                            break;
                                        }
                                    }
                                    if (propIndex < 0)
                                    {
                                        initStatesProp.arraySize++;
                                        propIndex = initStatesProp.arraySize - 1;
                                    }
                                    string initState  = initStatesProp.GetArrayElementAtIndex(propIndex).stringValue.Replace(controllerName + "/", null);
                                    int    stateIndex = Array.FindIndex(layer.stateMachine.states, s => s.state.name == initState);
                                    if (stateIndex < 0)
                                    {
                                        stateIndex = 0;
                                    }
                                    int newStateIndex = EditorGUILayout.Popup(stateIndex, layer.stateMachine.states.Select(s => s.state.name).ToArray(), GUILayout.Width(100));
                                    if (newStateIndex != stateIndex)
                                    {
                                        animator.enabled = true;
                                        animator.speed   = 0;
                                        animator.Play(layer.stateMachine.states[newStateIndex].state.name, animator.GetLayerIndex(controllerName + "Controller"));
                                        animator.Update(Time.deltaTime);
                                    }
                                    initStatesProp.GetArrayElementAtIndex(propIndex).stringValue = controllerName + "/" + layer.stateMachine.states[newStateIndex].state.name;
                                }
                                //删除Controller
                                if (GUILayout.Button("-", GUILayout.Width(20)))
                                {
                                    removeLayer = layer;
                                }
                                EditorGUILayout.EndHorizontal();
                                //Controller内容绘制
                                if (controllerFoldDic[controllerName])
                                {
                                    EditorGUI.indentLevel++;
                                    AnimatorState removeState = null;
                                    //状态绘制
                                    if (layer.stateMachine == null)
                                    {
                                        rebuildLayer = layer;
                                    }
                                    else
                                    {
                                        foreach (ChildAnimatorState state in layer.stateMachine.states)
                                        {
                                            EditorGUILayout.BeginHorizontal();
                                            EditorGUILayout.LabelField(state.state.name, "");
                                            if (EditorApplication.isPlaying && GUILayout.Button(">", GUILayout.Width(20)))
                                            {
                                                (target as UIObject).setController(controllerName, state.state.name);
                                            }
                                            if (GUILayout.Button("-", GUILayout.Width(20)))
                                            {
                                                removeState = state.state;
                                            }
                                            EditorGUILayout.EndHorizontal();
                                        }
                                        if (removeState != null)
                                        {
                                            if (removeState.motion is AnimationClip removeClip)
                                            {
                                                AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(removeClip));
                                            }
                                            layer.stateMachine.RemoveState(removeState);
                                        }
                                        EditorGUILayout.BeginHorizontal();
                                        //新建状态
                                        if (!controllerNewStateDic.ContainsKey(controllerName))
                                        {
                                            controllerNewStateDic.Add(controllerName, null);
                                        }
                                        controllerNewStateDic[controllerName] = EditorGUILayout.TextField(controllerNewStateDic[controllerName]);
                                        if (GUILayout.Button("AddState"))
                                        {
                                            if (layer.stateMachine.states.Any(s => s.state.name == controllerNewStateDic[controllerName]))
                                            {
                                                Debug.LogError(controllerName + "中已经存在同名的状态,无法添加" + controllerNewStateDic[controllerName]);
                                            }
                                            else if (string.IsNullOrEmpty(controllerNewStateDic[controllerName]))
                                            {
                                                Debug.LogError("Controller状态名称不能为空");
                                            }
                                            else
                                            {
                                                if (Directory.Exists(controllerDir))
                                                {
                                                    AnimationClip newClip = new AnimationClip();
                                                    AssetDatabase.CreateAsset(newClip, controllerDir + "/" + controllerName + "_" + controllerNewStateDic[controllerName] + ".anim");
                                                    AssetDatabase.SaveAssets();
                                                    AssetDatabase.Refresh();
                                                    AnimatorState newState = new AnimatorState()
                                                    {
                                                        name   = controllerNewStateDic[controllerName],
                                                        motion = newClip
                                                    };
                                                    layer.stateMachine.AddState(newState, new Vector3(250, layer.stateMachine.states.Length * 50));

                                                    EditorUtility.SetDirty(controller);
                                                    AssetDatabase.AddObjectToAsset(newState, controller);
                                                    AssetDatabase.SaveAssets();
                                                    AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(controller));
                                                }
                                                else
                                                {
                                                    Debug.LogError("文件夹" + controllerDir + "不存在", target);
                                                }
                                            }
                                            controllerNewStateDic.Remove(controllerName);
                                        }
                                        EditorGUILayout.EndHorizontal();
                                    }
                                    EditorGUI.indentLevel--;
                                }
                            }
                        }
                        //删除Controller的实际处理
                        if (removeLayer != null)
                        {
                            AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(controller) + "/" + removeLayer.stateMachine.name);
                            controller.RemoveLayer(Array.FindIndex(controller.layers, l => l.name == removeLayer.name));
                            EditorUtility.SetDirty(controller);
                            AssetDatabase.SaveAssets();
                            AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(controller));
                        }
                        //stateMachine的Layer丢失了似乎重新新建它是没用的。那就只能试试看重建它了。
                        if (rebuildLayer != null)
                        {
                            string controllerName = rebuildLayer.name.Replace("Controller", string.Empty);
                            controller.RemoveLayer(Array.FindIndex(controller.layers, l => l.name == rebuildLayer.name));
                            AnimatorControllerLayer layer = new AnimatorControllerLayer()
                            {
                                name          = controllerName + "Controller",
                                defaultWeight = 1,
                                stateMachine  = new AnimatorStateMachine()
                                {
                                    name = controllerName + "Controller"
                                }
                            };
                            foreach (string animPath in Directory.GetFiles(controllerDir, "*.anim")
                                     .Select(s => s.Replace('\\', '/').Replace(Environment.CurrentDirectory.Replace('\\', '/') + "/", string.Empty)))
                            {
                                AnimationClip clip = AssetDatabase.LoadAssetAtPath <AnimationClip>(animPath);
                                Match         m    = Regex.Match(clip.name, @"(?<controller>\w+)_(?<state>\w+)");
                                if (m.Success && m.Groups["controller"].Value == controllerName)
                                {
                                    string        stateName = m.Groups["state"].Value;
                                    AnimatorState newState  = new AnimatorState()
                                    {
                                        name   = stateName,
                                        motion = clip
                                    };
                                    layer.stateMachine.AddState(newState, new Vector3(250, layer.stateMachine.states.Length * 50));
                                }
                            }
                            controller.AddLayer(layer);
                            EditorUtility.SetDirty(controller);
                            AssetDatabase.AddObjectToAsset(layer.stateMachine, controller);
                            AssetDatabase.SaveAssets();
                            AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(controller));
                        }
                        //新建Controller
                        EditorGUILayout.BeginHorizontal();
                        newControllerName = EditorGUILayout.TextField(newControllerName);
                        if (GUILayout.Button("AddController"))
                        {
                            if (controller.layers.Any(l => l.name == newControllerName + "Controller"))
                            {
                                Debug.LogError("已经存在同名Controller,无法添加" + newControllerName);
                            }
                            else if (string.IsNullOrEmpty(newControllerName))
                            {
                                Debug.LogError("Controller名称不能为空");
                            }
                            else
                            {
                                AnimatorControllerLayer newLayer = new AnimatorControllerLayer
                                {
                                    name          = newControllerName + "Controller",
                                    defaultWeight = 1,
                                    stateMachine  = new AnimatorStateMachine()
                                };
                                controller.AddLayer(newLayer);
                                EditorUtility.SetDirty(controller);
                                AssetDatabase.AddObjectToAsset(newLayer.stateMachine, controller);
                                AssetDatabase.SaveAssets();
                                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(controller));
                            }
                            newControllerName = null;
                        }
                        EditorGUILayout.EndHorizontal();
                        serializedObject.ApplyModifiedProperties();
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("无法同时编辑多个物体的动画控制器");
                }
            }
            base.OnInspectorGUI();//Generated fields
        }
Ejemplo n.º 14
0
    public override void OnInspectorGUI()
    {
        Map m = (Map)target;

        showDimensions = EditorGUILayout.Foldout(showDimensions, "Map Dimensions");
        if (showDimensions)
        {
            //		EditorGUI.indentLevel++;
            GUILayout.BeginHorizontal();
            GUILayout.Label("Width", GUILayout.Width(78));
            float nextXSz = EditorGUILayout.FloatField(m.size.x, GUILayout.Width(32));
            GUILayout.Label("Height", GUILayout.Width(78));
            float   nextYSz = EditorGUILayout.FloatField(m.size.y, GUILayout.Width(32));
            Vector2 nextSz  = new Vector2(nextXSz, nextYSz);
            if (nextSz != m.size)
            {
                RegisterUndo("Map Size Change");
                m.size = nextSz;
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Side Length", GUILayout.Width(78));
            float nextLength = EditorGUILayout.FloatField(m.sideLength, GUILayout.Width(32));
            if (nextLength != m.sideLength)
            {
                RegisterUndo("Map Side Length Change");
                m.sideLength = nextLength;
            }
            GUILayout.Label("Tile Height", GUILayout.Width(78));
            float nextHeight = EditorGUILayout.FloatField(m.tileHeight, GUILayout.Width(32));
            if (nextHeight != m.tileHeight)
            {
                RegisterUndo("Map Side Height Change");
                m.tileHeight = nextHeight;
            }
            GUILayout.EndHorizontal();
            //		EditorGUI.indentLevel--;
        }

        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Edit Z", GUILayout.Width(78));
        int nextZ = EditorGUILayout.IntSlider(editZ, 0, 20);

        if (nextZ != editZ)
        {
//			RegisterUndo(target, "Map Height Selection");
            editZ = nextZ;
        }
        GUILayout.EndHorizontal();

        EditorGUILayout.Separator();

        EditorGUILayout.BeginHorizontal();
        GUIContent[] toolbarOptions = new GUIContent[3];
        toolbarOptions[(int)EditMode.AddRemove] = new GUIContent("Add/Remove");
        toolbarOptions[(int)EditMode.Reshape]   = new GUIContent("Reshape");
        toolbarOptions[(int)EditMode.Paint]     = new GUIContent("Paint");
        EditMode nextMode = (EditMode)GUILayout.Toolbar((int)editMode, toolbarOptions);

        EditorGUILayout.EndHorizontal();
        if (nextMode != editMode)
        {
            editMode        = nextMode;
            editModeChanged = true;
        }
        if (editMode == EditMode.AddRemove || editMode == EditMode.Reshape)
        {
            //show inset/offset settings for current stamp
            GUILayout.BeginHorizontal();
            GUILayout.Label("Invisible", GUILayout.Width(78));
            makeInvisibleTiles = EditorGUILayout.Toggle(makeInvisibleTiles);
            GUILayout.EndHorizontal();
            GUILayout.Label("Side Insets");
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("-X", GUILayout.Width(32));
            sideInsets[(int)Neighbors.FrontLeftIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.FrontLeftIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.BackRightIdx]);
            GUILayout.Label("+X", GUILayout.Width(32));
            sideInsets[(int)Neighbors.BackRightIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.BackRightIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.FrontLeftIdx]);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("-Y", GUILayout.Width(32));
            sideInsets[(int)Neighbors.FrontRightIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.FrontRightIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.BackLeftIdx]);
            GUILayout.Label("+Y", GUILayout.Width(32));
            sideInsets[(int)Neighbors.BackLeftIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.BackLeftIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.FrontRightIdx]);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("-Z", GUILayout.Width(32));
            sideInsets[(int)Neighbors.BottomIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.BottomIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.TopIdx]);
            GUILayout.Label("+Z", GUILayout.Width(32));
            sideInsets[(int)Neighbors.TopIdx] = Mathf.Clamp(EditorGUILayout.FloatField(sideInsets[(int)Neighbors.TopIdx], GUILayout.Width(32)), 0, 1.0f - sideInsets[(int)Neighbors.BottomIdx]);
            EditorGUILayout.EndHorizontal();
            // GUILayout.Label("Corner Insets (not yet implemented)");
            // EditorGUILayout.BeginHorizontal();
            // GUILayout.Label(" 0", GUILayout.Width(32));
            // cornerInsets[(int)Corners.Front] = Mathf.Clamp(EditorGUILayout.FloatField(cornerInsets[(int)Corners.Front], GUILayout.Width(32)), 0, 1.0f);
            // GUILayout.Label("+X", GUILayout.Width(32));
            // cornerInsets[(int)Corners.Right] = Mathf.Clamp(EditorGUILayout.FloatField(cornerInsets[(int)Corners.Right], GUILayout.Width(32)), 0, 1.0f);
            // EditorGUILayout.EndHorizontal();
            // EditorGUILayout.BeginHorizontal();
            // GUILayout.Label("+Y", GUILayout.Width(32));
            // cornerInsets[(int)Corners.Left ] = Mathf.Clamp(EditorGUILayout.FloatField(cornerInsets[(int)Corners.Left ], GUILayout.Width(32)), 0, 1.0f);
            // GUILayout.Label("+XY", GUILayout.Width(32));
            // cornerInsets[(int)Corners.Back ] = Mathf.Clamp(EditorGUILayout.FloatField(cornerInsets[(int)Corners.Back ], GUILayout.Width(32)), 0, 1.0f);
            // EditorGUILayout.EndHorizontal();
        }
        else if (editMode == EditMode.Paint)
        {
            EditorGUILayout.Separator();
            specScrollPos = EditorGUILayout.BeginScrollView(specScrollPos, true, false, GUILayout.Height(80));
            EditorGUILayout.BeginHorizontal(GUILayout.Height(64));
            //show list of texture specs controls
            //a texture spec is a rectangular Texture2D with some metadata
            //only for now, there's no metadata.
            //this metadata gets stored in the map object, which composes the
            //textures into an atlas. uvs are mapped from this atlas.
            //changes to the texture spec list force recreation of the mesh.
            //texture spec info for each face is stored as part of the MapTile class.
            Texture2D[] textures = new Texture2D[m.TileSpecCount + 1];
            if (specPlaceholderTexture == null)
            {
                specPlaceholderTexture = EditorGUIUtility.LoadRequired("SpecPlaceholder.png") as Texture2D;
            }
            for (int i = 0; i < m.TileSpecCount; i++)
            {
                Texture2D specTex = m.TileSpecAt(i).texture;
                if (specTex != null)
                {
                    textures[i] = specTex;
                }
                else
                {
                    textures[i] = specPlaceholderTexture;
                }
            }
            textures[m.TileSpecCount] = specPlaceholderTexture;
            var names = new Dictionary <string, int>();
            for (int i = 0; i < textures.Length; i++)
            {
                Texture2D tex = textures[i];
                GUIUpdateTexture(tex, i, names);
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndScrollView();
            string n = GUI.GetNameOfFocusedControl();
            if (names.ContainsKey(n))
            {
                if (names[n] < m.TileSpecCount)
                {
                    specSelectedSpec = names[n];
                }
            }
            EditorGUI.indentLevel++;
            //now, show the parameters for this spec
            bool oldEnabled = GUI.enabled;
            GUI.enabled = specSelectedSpec < m.TileSpecCount;

            if (GUILayout.Button("Delete Tile"))
            {
                RegisterUndo("Delete Tile Spec");
                m.RemoveTileSpecAt(specSelectedSpec);
                while (specSelectedSpec >= m.TileSpecCount)
                {
                    specSelectedSpec--;
                    if (specSelectedSpec < 0)
                    {
                        specSelectedSpec = 0; break;
                    }
                }
            }
            GUI.enabled = oldEnabled;
            EditorGUI.indentLevel--;
            EditorGUILayout.Separator();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Ejemplo n.º 15
0
    //해당 윈도우에 GUI들을 여기서 랜더링한다.
    void OnGUI()
    {
        /*
         *              //label
         *              GUI.Label(new Rect(0,0,240,100), "this is text for test OnGUI.");
         *
         *              //button
         *              if( true == GUI.Button(new Rect(0,100,240,100), "TestButton") )
         *              {
         *                      Debug.Log("TestButton is clicked.");
         *              }
         *
         *              //textfield
         *              mInputString = GUI.TextField(new Rect(0,200,240,100), mInputString);
         *              Debug.Log(mInputString);
         */



        EditorGUILayout.BeginVertical();

        if (true == GUILayout.Button("TestGUILayoutButton_0", GUILayout.Width(240), GUILayout.Height(50)))
        {
        }

        //EditorGUILayout.Space();
        GUILayout.Space(10);

        if (true == GUILayout.Button("TestGUILayoutButton_1", GUILayout.Width(240), GUILayout.Height(50)))
        {
        }

        EditorGUILayout.EndVertical();



        //GUILayout.Space(50);



        mIsFoldout = EditorGUILayout.Foldout(mIsFoldout, "Test Foldout");
        if (true == mIsFoldout)
        {
            EditorGUILayout.BeginVertical();

            //label
            int ti = 0;
            for (ti = 0; ti < 5; ti++)
            {
                EditorGUILayout.LabelField("LabelField_" + ti.ToString(), EditorStyles.helpBox);
            }

            //button
            if (true == GUILayout.Button("Button", EditorStyles.miniButton, GUILayout.Width(100), GUILayout.Height(20)))
            {
            }

            //textfield
            mInputString = EditorGUILayout.TextField(mInputString);

            EditorGUILayout.EndVertical();
        }
    }
        void DrawPropertyOverride(RuntimePrefabPropertyOverride propertyOverride)
        {
            m_ExpandedStates.TryGetValue(propertyOverride, out var expandedState);
            var wasExpanded = expandedState;

            expandedState = EditorGUILayout.Foldout(expandedState, propertyOverride.PropertyPath, true);
            if (expandedState != wasExpanded)
            {
                m_ExpandedStates[propertyOverride] = expandedState;
            }

            if (expandedState)
            {
                using (new EditorGUI.IndentLevelScope())
                {
                    EditorGUILayout.TextField("Property Path", propertyOverride.PropertyPath);
                    EditorGUILayout.TextField("Transform Path", propertyOverride.TransformPath);
                    EditorGUILayout.IntField("Component Index", propertyOverride.ComponentIndex);

                    switch (propertyOverride)
                    {
                    case IRuntimePrefabOverrideUnityObject unityObjectProperty:
                        EditorGUILayout.ObjectField("Value", unityObjectProperty.Value, typeof(UnityObject), true);
                        break;

                    case IRuntimePrefabOverrideUnityObjectReference objectReferenceProperty:
                        var objectReference = objectReferenceProperty.Value;
                        EditorGUILayout.IntField("Scene ID", objectReference.sceneID);
                        EditorGUILayout.TextField("Guid", objectReference.guid);
                        EditorGUILayout.LongField("File ID", objectReference.fileId);
                        break;

                    case IRuntimePrefabOverride <AnimationCurve> animationCurveProperty:
                        EditorGUILayout.CurveField("Value", animationCurveProperty.Value);
                        break;

                    case RuntimePrefabPropertyOverrideList listProperty:
                        foreach (var element in listProperty.List)
                        {
                            DrawPropertyOverride(element);
                        }

                        break;

                    case IRuntimePrefabOverride <bool> boolProperty:
                        EditorGUILayout.Toggle("Value", boolProperty.Value);
                        break;

                    case IRuntimePrefabOverride <char> charProperty:
                        EditorGUILayout.TextField("Value", charProperty.Value.ToString());
                        break;

                    case IRuntimePrefabOverride <float> floatProperty:
                        EditorGUILayout.FloatField("Value", floatProperty.Value);
                        break;

                    case IRuntimePrefabOverride <int> intProperty:
                        EditorGUILayout.IntField("Value", intProperty.Value);
                        break;

                    case IRuntimePrefabOverride <long> longProperty:
                        EditorGUILayout.LongField("Value", longProperty.Value);
                        break;

                    case IRuntimePrefabOverride <string> stringProperty:
                        EditorGUILayout.TextField("Value", stringProperty.Value);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 17
0
    override public void OnInspectorGUI()
    {
        Draw script = (Draw)target;

        GUILayout.Space(5);

        GUILayout.Label("Draw Method", EditorStyles.boldLabel);

        script.drawStyle = (Draw.DrawStyle)EditorGUILayout.EnumPopup("Draw Style", script.drawStyle);

        // Style Specific Options
        switch (script.drawStyle)
        {
        case Draw.DrawStyle.Continuous:
            script.samplingRate = EditorGUILayout.FloatField("Sample Rate", script.samplingRate);
            break;

        case Draw.DrawStyle.ContinuousClosingDistance:
            script.samplingRate    = EditorGUILayout.FloatField("Sample Rate", script.samplingRate);
            script.closingDistance = EditorGUILayout.FloatField("Closing Distance", script.closingDistance);
            break;

        case Draw.DrawStyle.PointMaxVertex:
            script.maxVertices = EditorGUILayout.IntField("Max Allowed Vertices", script.maxVertices);
            break;

        case Draw.DrawStyle.PointClosingDistance:
            script.closingDistance = EditorGUILayout.FloatField("Closing Distance", script.closingDistance);
            break;
        }

        script.drawSettings.axis = (Polydraw.Axis)EditorGUILayout.EnumPopup(script.drawSettings.axis);

        script.inputCamera = (Camera)EditorGUILayout.ObjectField(new GUIContent("Input Camera", "The camera that listens for mouse input.  Must be orthographic."), script.inputCamera, typeof(Camera), true);

        GUILayout.Space(5);

        showDrawSettings = EditorGUILayout.Foldout(showDrawSettings, "Drawing Settings");
        if (showDrawSettings)
        {
            script.showPointMarkers = EditorGUILayout.BeginToggleGroup("Show Vertex Markers", script.showPointMarkers);
            script.pointMarker      = (GameObject)EditorGUILayout.ObjectField("Point Marker", script.pointMarker, typeof(GameObject), true);
            EditorGUILayout.EndToggleGroup();

            script.drawMeshInProgress = EditorGUILayout.Toggle("Draw Preview Mesh", script.drawMeshInProgress);

            script.drawLineRenderer = EditorGUILayout.BeginToggleGroup("Draw Line Renderer", script.drawLineRenderer);
            script.lineRenderer     = (LineRenderer)EditorGUILayout.ObjectField(new GUIContent("Trail Renderer", "If left null, a default trail renderer will be applied automatically."), script.lineRenderer, typeof(LineRenderer), true);
            if (script.lineRenderer == null)
            {
                script.lineWidth = EditorGUILayout.FloatField("Trail Renderer Width", script.lineWidth);
            }
            EditorGUILayout.EndToggleGroup();

            script.drawSettings.requireMinimumArea = EditorGUILayout.BeginToggleGroup(new GUIContent("Require Minimum Area to Draw Object", "If true, the drawn polygon must have an area greater than this value in order to be generated.  Perfect for use with Drawing Style Continuous."), script.drawSettings.requireMinimumArea);
            script.drawSettings.minimumAreaToDraw  = EditorGUILayout.FloatField("Minimum Area", script.drawSettings.minimumAreaToDraw);
            EditorGUILayout.EndToggleGroup();

            script.useDistanceCheck = EditorGUILayout.BeginToggleGroup(new GUIContent("Use Distance Check", "If final user set point is greater than `x` distance from origin point, polygon will not be drawn"), script.useDistanceCheck);
            script.maxDistance      = EditorGUILayout.FloatField("Max Distance from Origin", script.maxDistance);
            EditorGUILayout.EndToggleGroup();
        }

        showMeshSettings = EditorGUILayout.Foldout(showMeshSettings, "Mesh Settings");
        if (showMeshSettings)
        {
            script.drawSettings.meshName = EditorGUILayout.TextField("Mesh Name", script.drawSettings.meshName);

            script.drawSettings.frontMaterial = (Material)EditorGUILayout.ObjectField("Material", script.drawSettings.frontMaterial, typeof(Material), false);

            script.drawSettings.anchor = (Draw.Anchor)EditorGUILayout.EnumPopup("Mesh Anchor", script.drawSettings.anchor);

            script.drawSettings.zPosition = EditorGUILayout.FloatField("Z Origin", script.drawSettings.zPosition);

            script.drawSettings.faceOffset = EditorGUILayout.FloatField(new GUIContent("Z Offset", "Allows for custom offsets.  See docs for details."), script.drawSettings.faceOffset);

            script.drawSettings.generateBackFace = EditorGUILayout.Toggle("Generate Back", script.drawSettings.generateBackFace);

            script.drawSettings.generateSide = EditorGUILayout.BeginToggleGroup("Generate Sides", script.drawSettings.generateSide);

            script.drawSettings.sideLength   = EditorGUILayout.FloatField("Side Length", script.drawSettings.sideLength);
            script.drawSettings.sideMaterial = (Material)EditorGUILayout.ObjectField("Side Material", script.drawSettings.sideMaterial, typeof(Material), false);

            EditorGUILayout.EndToggleGroup();

            script.drawSettings.drawEdgePlanes = EditorGUILayout.BeginToggleGroup("Draw Edge Planes", script.drawSettings.drawEdgePlanes);

            script.drawSettings.edgeMaterial       = (Material)EditorGUILayout.ObjectField("Edge Material", script.drawSettings.edgeMaterial, typeof(Material), false);
            script.drawSettings.edgeLengthModifier = EditorGUILayout.FloatField(new GUIContent("Edge Length Modifier", "Multiply the length of the plane by this amount.  1 = no change, 1.3 = 33% longer."), script.drawSettings.edgeLengthModifier);
            script.drawSettings.edgeHeight         = EditorGUILayout.FloatField(new GUIContent("Edge Height", "Absolute value; how tall to make edge planes."), script.drawSettings.edgeHeight);
            script.drawSettings.minLengthToDraw    = EditorGUILayout.FloatField(new GUIContent("Minimum Edge Length", "Edges with a length less than this amount will not be drawn."), script.drawSettings.minLengthToDraw);
            script.drawSettings.edgeOffset         = EditorGUILayout.FloatField(new GUIContent("Edge Z Offset", "Value to scoot mesh + or - from Z Position."), script.drawSettings.edgeOffset);
            script.drawSettings.maxAngle           = EditorGUILayout.FloatField(new GUIContent("Maximum Slope", "Edge Z rotation must be less than this amount to be drawn.  Set to 180 to draw a complete loop, or leave at 45 to only draw up facing planes."), script.drawSettings.maxAngle);
            script.drawSettings.areaRelativeHeight = EditorGUILayout.Toggle(new GUIContent("Area Relative Height", "If true, the height of each plane will be modified by how large the finalized mesh is."), script.drawSettings.areaRelativeHeight);
            if (script.drawSettings.areaRelativeHeight)
            {
                script.drawSettings.minEdgeHeight = EditorGUILayout.FloatField("Minimum Edge Height", script.drawSettings.minEdgeHeight);
                script.drawSettings.maxEdgeHeight = EditorGUILayout.FloatField("Maximum Edge Height", script.drawSettings.maxEdgeHeight);
            }

            EditorGUILayout.EndToggleGroup();

            script.drawSettings.uvScale = EditorGUILayout.Vector2Field("UV Scale", script.drawSettings.uvScale);
        }

        showGameObjectSettings = EditorGUILayout.Foldout(showGameObjectSettings, "GameObject Settings");
        if (showGameObjectSettings)
        {
            script.drawSettings.useTag = EditorGUILayout.BeginToggleGroup(new GUIContent("Apply Tag", "Tag must exist prior to assignment."), script.drawSettings.useTag);
            script.drawSettings.tagVal = EditorGUILayout.TextField("Tag", script.drawSettings.tagVal);
            EditorGUILayout.EndToggleGroup();

            script.maxAllowedObjects = EditorGUILayout.IntField("Max Drawn Objects Allowed", script.maxAllowedObjects);
        }

        showCollisionSettings = EditorGUILayout.Foldout(showCollisionSettings, "Physics Settings");
        if (showCollisionSettings)
        {
            script.drawSettings.colliderType = (Draw.ColliderType)EditorGUILayout.EnumPopup(new GUIContent("Collison", "If set to mesh, a Mesh Collider will be applied.  If set to Box, a series of thin box colliders will be generated bordering the edges, allowing for concave interactions.  None means no collider will be applied."), script.drawSettings.colliderType);

            if (script.drawSettings.colliderType == Draw.ColliderType.BoxCollider)
            {
                if (!script.drawSettings.manualColliderDepth)
                {
                    script.drawSettings.colDepth = script.drawSettings.sideLength;
                }

                script.drawSettings.manualColliderDepth = EditorGUILayout.BeginToggleGroup(new GUIContent("Manual Collider Depth", "If false, the side length will be used as the depth value."), script.drawSettings.manualColliderDepth);

                script.drawSettings.colDepth = EditorGUILayout.FloatField("Collider Depth", script.drawSettings.colDepth);

                EditorGUILayout.EndToggleGroup();
            }

            switch (script.drawSettings.colliderType)
            {
            case Draw.ColliderType.BoxCollider:
                break;

            case Draw.ColliderType.MeshCollider:
                script.drawSettings.forceConvex = EditorGUILayout.Toggle("Force Convex", script.drawSettings.forceConvex);
                break;

            case Draw.ColliderType.None:
                break;
            }

            script.drawSettings.applyRigidbody = EditorGUILayout.BeginToggleGroup("Apply Rigidbody", script.drawSettings.applyRigidbody);

            script.drawSettings.useGravity = EditorGUILayout.Toggle("Use Gravity", script.drawSettings.useGravity);

            script.drawSettings.isKinematic = EditorGUILayout.Toggle("Is Kinematic", script.drawSettings.isKinematic);

            script.drawSettings.areaRelativeMass = EditorGUILayout.Toggle("Area Relative Mass", script.drawSettings.areaRelativeMass);
            if (script.drawSettings.areaRelativeMass)
            {
                script.drawSettings.massModifier = EditorGUILayout.FloatField("Mass Modifier", script.drawSettings.massModifier);
            }
            else
            {
                script.drawSettings.mass = EditorGUILayout.FloatField("Mass", script.drawSettings.mass);
            }
            EditorGUILayout.EndToggleGroup();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(script);
        }
    }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            SerializedProperty serverUrl = serializedObject.FindProperty("ServerUrl");

            serverUrl.stringValue = BacktraceConfiguration.UpdateServerUrl(serverUrl.stringValue);
            EditorGUILayout.PropertyField(serverUrl, new GUIContent(BacktraceConfigurationLabels.LABEL_SERVER_URL));
            if (!BacktraceConfiguration.ValidateServerUrl(serverUrl.stringValue))
            {
                EditorGUILayout.HelpBox("Please insert valid Backtrace server url!", MessageType.Error);
            }

            EditorGUILayout.PropertyField(
                serializedObject.FindProperty("HandleUnhandledExceptions"),
                new GUIContent(BacktraceConfigurationLabels.LABEL_HANDLE_UNHANDLED_EXCEPTION));

            EditorGUILayout.PropertyField(
                serializedObject.FindProperty("ReportPerMin"),
                new GUIContent(BacktraceConfigurationLabels.LABEL_REPORT_PER_MIN));

            GUIStyle clientAdvancedSettingsFoldout = new GUIStyle(EditorStyles.foldout);

            showClientAdvancedSettings = EditorGUILayout.Foldout(showClientAdvancedSettings, "Client advanced settings", clientAdvancedSettingsFoldout);
            if (showClientAdvancedSettings)
            {
#if UNITY_2018_4_OR_NEWER
                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("IgnoreSslValidation"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_IGNORE_SSL_VALIDATION));
#endif
#if UNITY_ANDROID
                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("HandleANR"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_HANDLE_ANR));

                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("SymbolsUploadToken"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_SYMBOLS_UPLOAD_TOKEN));
#endif
                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("UseNormalizedExceptionMessage"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_USE_NORMALIZED_EXCEPTION_MESSAGE));
#if UNITY_STANDALONE_WIN
                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("SendUnhandledGameCrashesOnGameStartup"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_SEND_UNHANDLED_GAME_CRASHES_ON_STARTUP));
#endif

                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("ReportFilterType"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_REPORT_FILTER));

                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("NumberOfLogs"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_NUMBER_OF_LOGS));

                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("PerformanceStatistics"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_PERFORMANCE_STATISTICS));

                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("DestroyOnLoad"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_DESTROY_CLIENT_ON_SCENE_LOAD));

                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("Sampling"),
                    new GUIContent(BacktraceConfigurationLabels.LABEL_SAMPLING));

                SerializedProperty gameObjectDepth = serializedObject.FindProperty("GameObjectDepth");
                EditorGUILayout.PropertyField(gameObjectDepth, new GUIContent(BacktraceConfigurationLabels.LABEL_GAME_OBJECT_DEPTH));

                if (gameObjectDepth.intValue < -1)
                {
                    EditorGUILayout.HelpBox("Please insert value greater or equal -1", MessageType.Error);
                }
            }
#if !UNITY_SWITCH
            SerializedProperty enabled = serializedObject.FindProperty("Enabled");
            EditorGUILayout.PropertyField(enabled, new GUIContent(BacktraceConfigurationLabels.LABEL_ENABLE_DATABASE));
            bool databaseEnabled = enabled.boolValue;
#else
            bool databaseEnabled = false;
#endif
            if (databaseEnabled)
            {
                SerializedProperty databasePath = serializedObject.FindProperty("DatabasePath");
                EditorGUILayout.PropertyField(databasePath, new GUIContent(BacktraceConfigurationLabels.LABEL_PATH));
                if (string.IsNullOrEmpty(databasePath.stringValue))
                {
                    EditorGUILayout.HelpBox("Please insert valid Backtrace database path!", MessageType.Error);
                }


                GUIStyle databaseFoldout = new GUIStyle(EditorStyles.foldout);
                showDatabaseSettings = EditorGUILayout.Foldout(showDatabaseSettings, "Advanced database settings", databaseFoldout);
                if (showDatabaseSettings)
                {
                    EditorGUILayout.PropertyField(
                        serializedObject.FindProperty("DeduplicationStrategy"),
                        new GUIContent(BacktraceConfigurationLabels.LABEL_DEDUPLICATION_RULES));

#if UNITY_STANDALONE_WIN
                    EditorGUILayout.PropertyField(
                        serializedObject.FindProperty("MinidumpType"),
                        new GUIContent(BacktraceConfigurationLabels.LABEL_MINIDUMP_SUPPORT));
#endif

#if UNITY_STANDALONE_LINUX || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN
                    EditorGUILayout.PropertyField(
                        serializedObject.FindProperty("AddUnityLogToReport"),
                        new GUIContent(BacktraceConfigurationLabels.LABEL_ADD_UNITY_LOG));
#endif

#if UNITY_ANDROID || UNITY_IOS
                    EditorGUILayout.PropertyField(
                        serializedObject.FindProperty("CaptureNativeCrashes"),
                        new GUIContent(BacktraceConfigurationLabels.CAPTURE_NATIVE_CRASHES));
#endif
                    EditorGUILayout.PropertyField(
                        serializedObject.FindProperty("AutoSendMode"),
                        new GUIContent(BacktraceConfigurationLabels.LABEL_AUTO_SEND_MODE));

                    EditorGUILayout.PropertyField(
                        serializedObject.FindProperty("CreateDatabase"),
                        new GUIContent(BacktraceConfigurationLabels.LABEL_CREATE_DATABASE_DIRECTORY));

                    EditorGUILayout.PropertyField(
                        serializedObject.FindProperty("GenerateScreenshotOnException"),
                        new GUIContent(BacktraceConfigurationLabels.LABEL_GENERATE_SCREENSHOT_ON_EXCEPTION));

                    SerializedProperty maxRecordCount = serializedObject.FindProperty("MaxRecordCount");
                    EditorGUILayout.PropertyField(maxRecordCount, new GUIContent(BacktraceConfigurationLabels.LABEL_MAX_REPORT_COUNT));

                    SerializedProperty maxDatabaseSize = serializedObject.FindProperty("MaxDatabaseSize");
                    EditorGUILayout.PropertyField(maxDatabaseSize, new GUIContent(BacktraceConfigurationLabels.LABEL_MAX_DATABASE_SIZE));

                    SerializedProperty retryInterval = serializedObject.FindProperty("RetryInterval");
                    EditorGUILayout.PropertyField(retryInterval, new GUIContent(BacktraceConfigurationLabels.LABEL_RETRY_INTERVAL));

                    EditorGUILayout.LabelField("Backtrace database require at least one retry.");
                    SerializedProperty retryLimit = serializedObject.FindProperty("RetryLimit");
                    EditorGUILayout.PropertyField(retryLimit, new GUIContent(BacktraceConfigurationLabels.LABEL_RETRY_LIMIT));

                    SerializedProperty retryOrder = serializedObject.FindProperty("RetryOrder");
                    EditorGUILayout.PropertyField(retryOrder, new GUIContent(BacktraceConfigurationLabels.LABEL_RETRY_ORDER));
                }
            }
            serializedObject.ApplyModifiedProperties();
        }
    void AddFieldGUI()
    {
        EditorGUILayout.Space();
        m_isAddFoldField = EditorGUILayout.Foldout(m_isAddFoldField, "新增字段");
        EditorGUI.indentLevel++;

        if (m_isAddFoldField)
        {
            m_newFieldName = EditorGUILayout.TextField("字段名", m_newFieldName);
            FieldType typeTmp = (FieldType)EditorGUILayout.EnumPopup("字段类型", m_newAddType);

            bool isNewFieldType = false;

            if (typeTmp != m_newAddType)
            {
                m_newAddType   = typeTmp;
                isNewFieldType = true;
            }

            m_addNoteContent = EditorGUILayout.TextField("注释", m_addNoteContent);

            if (typeTmp == FieldType.Enum)
            {
                int newEnumTypeIndex = EditorGUILayout.Popup("枚举类型", m_newEnumTypeIndex, EditorTool.GetAllEnumType());

                if (newEnumTypeIndex != m_newEnumTypeIndex)
                {
                    m_newEnumTypeIndex = newEnumTypeIndex;
                    isNewFieldType     = true;
                }
            }

            //更改字段类型重设初始值
            if (isNewFieldType)
            {
                if (typeTmp == FieldType.Enum)
                {
                    m_newFieldDefaultValue = new SingleField(m_newAddType, null, EditorTool.GetAllEnumType()[m_newEnumTypeIndex]).m_content;
                }
                else
                {
                    m_newFieldDefaultValue = new SingleField(m_newAddType, null, null).m_content;
                }
            }

            //是否是一个合理的字段名
            bool isShowButton = true;

            if (m_newFieldName == "")
            {
                isShowButton = false;
            }

            if (m_currentData.TableKeys.Contains(m_newFieldName))
            {
                isShowButton = false;
                EditorGUILayout.TextField("字段名不能重复!", EditorGUIStyleData.s_WarnMessageLabel);
            }

            m_newFieldDefaultValue = EditorUtilGUI.FieldGUI_Type(m_newAddType, EditorTool.GetAllEnumType()[m_newEnumTypeIndex], m_newFieldDefaultValue, "默认值");

            if (isShowButton)
            {
                if (GUILayout.Button("新增字段"))
                {
                    if (m_newAddType == FieldType.Enum)
                    {
                        AddField(m_currentData, m_newFieldName, m_newAddType, m_newFieldDefaultValue, EditorTool.GetAllEnumType()[m_newEnumTypeIndex], m_addNoteContent);
                    }
                    else
                    {
                        AddField(m_currentData, m_newFieldName, m_newAddType, m_newFieldDefaultValue, null, m_addNoteContent);
                    }

                    m_newFieldName         = "";
                    m_newFieldDefaultValue = "";
                    m_addNoteContent       = "";
                    m_newAddType           = FieldType.String;
                    m_newEnumTypeIndex     = 0;
                }
            }
        }
    }
Ejemplo n.º 20
0
    public override void OnInspectorGUI()
    {
        MegaCachePointCloud mod = (MegaCachePointCloud)target;

        serializedObject.Update();

#if !UNITY_5 && !UNITY_2017 && !UNITY_2018
        EditorGUIUtility.LookLikeControls();
#endif

        EditorGUILayout.PropertyField(_prop_particle, new GUIContent("Particle System"));
        EditorGUILayout.PropertyField(_prop_importscale, new GUIContent("Import Scale"));
        EditorGUILayout.PropertyField(_prop_sizescale, new GUIContent("Size Scale"));

        mod.playscale = EditorGUILayout.FloatField("Play Scale", mod.playscale);
        mod.playsize  = EditorGUILayout.FloatField("Play Size", mod.playsize);
        //mod.color = EditorGUILayout.ColorField("Color", mod.color);

        EditorGUILayout.PropertyField(_prop_framenum, new GUIContent("Frame Num"));
        EditorGUILayout.PropertyField(_prop_time, new GUIContent("Time"));
        EditorGUILayout.PropertyField(_prop_animate, new GUIContent("Animate"));
        EditorGUILayout.PropertyField(_prop_fps, new GUIContent("Fps"));
        EditorGUILayout.PropertyField(_prop_speed, new GUIContent("Speed"));
        EditorGUILayout.PropertyField(_prop_loopmode, new GUIContent("Loop Mode"));


        EditorGUILayout.BeginVertical("box");
        mod.showdataimport = EditorGUILayout.Foldout(mod.showdataimport, "Data Import");

        if (mod.showdataimport)
        {
            EditorGUILayout.PropertyField(_prop_firstframe, new GUIContent("First"));
            EditorGUILayout.PropertyField(_prop_lastframe, new GUIContent("Last"));
            EditorGUILayout.PropertyField(_prop_skip, new GUIContent("Skip"));
            EditorGUILayout.PropertyField(_prop_yup, new GUIContent("Y Up Change"));

            //int val = 0;
            //mod.decformat = EditorGUILayout.IntSlider("Format name" + val.ToString("D" + mod.decformat) + ".csv", mod.decformat, 1, 6);
            //mod.namesplit = EditorGUILayout.TextField("Name Split Char", mod.namesplit);

            if (GUILayout.Button("Load Frames"))
            {
                string file = EditorUtility.OpenFilePanel("Point Cloud CSV File", mod.lastpath, "csv");

                if (file != null && file.Length > 1)
                {
                    mod.lastpath = file;
                    LoadPC(mod, file, mod.firstframe, mod.lastframe, mod.skip);
                }
            }
        }

        EditorGUILayout.EndVertical();

        string infstring = "";
        if (mod.image)
        {
            infstring  = "Current Memory: " + 0 + "KB";
            infstring += "\nMax Points: " + mod.image.maxpoints;
        }

        EditorGUILayout.HelpBox(infstring, MessageType.None);

        if (GUI.changed)
        {
            serializedObject.ApplyModifiedProperties();
            EditorUtility.SetDirty(target);
        }
    }
Ejemplo n.º 21
0
    public override void OnInspectorGUI()
    {
        if (_needReimport && _guiDrawn)
        {
            UpdateAllSettings();
            _needReimport = false;
        }

        Undo.RecordObject(target, "FuseSDK modified");

        _self = (FuseSDK)target;

        GUILayout.Space(8);
        if (_logo != null)
        {
            GUILayout.Label(_logo);
        }
        GUILayout.Space(4);

        if (_needReimport)
        {
            var oldGUIColor = GUI.color;
            var newStyle    = new GUIStyle(EditorStyles.boldLabel);
            newStyle.fontStyle = FontStyle.Bold;
            newStyle.fontSize  = 24;
            GUI.color          = Color.yellow;
            GUILayout.Label("Updating Unity settings for Fuse...", newStyle);
            GUI.color = oldGUIColor;

            if (Event.current.type == EventType.Repaint)
            {
                _guiDrawn = true;
                EditorUtility.SetDirty(target);
            }
            return;
        }

        GUILayout.Space(4);

        _self.AndroidAppID = _stripRegex.Replace(EditorGUILayout.TextField("Android App ID", _self.AndroidAppID), "");
#if UNITY_ANDROID
        int idVer = CheckGameID(_self.AndroidAppID);
        if (idVer < -99)
        {
            EditorGUILayout.HelpBox("Invalid App ID: Valid form is XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX where X is a haxadecimal character", MessageType.Error);
        }
        else if (idVer < 0)
        {
            EditorGUILayout.HelpBox("Invalid App ID: Too short", MessageType.Error);
        }
        else if (idVer > 0)
        {
            EditorGUILayout.HelpBox("Invalid App ID: Too long", MessageType.Error);
        }
#endif
        _self.iOSAppID = _stripRegex.Replace(EditorGUILayout.TextField("iOS App ID", _self.iOSAppID), "");
#if UNITY_IOS
        int idVer = CheckGameID(_self.iOSAppID);
        if (idVer < -99)
        {
            EditorGUILayout.HelpBox("Invalid App ID: Valid form is XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX where X is a haxadecimal character", MessageType.Error);
        }
        else if (idVer < 0)
        {
            EditorGUILayout.HelpBox("Invalid App ID: Too short", MessageType.Error);
        }
        else if (idVer > 0)
        {
            EditorGUILayout.HelpBox("Invalid App ID: Too long", MessageType.Error);
        }
#endif

        GUILayout.Space(8);

        _self.GCM_SenderID = EditorGUILayout.TextField("GCM Sender ID", _self.GCM_SenderID);
        _self.registerForPushNotifications = EditorGUILayout.Toggle("Push Notifications", _self.registerForPushNotifications);

        if (_self.registerForPushNotifications && !string.IsNullOrEmpty(_self.AndroidAppID) && string.IsNullOrEmpty(_self.GCM_SenderID))
        {
            EditorGUILayout.HelpBox("GCM Sender ID is required for Push Notifications on Android", MessageType.Warning);
        }

        GUILayout.Space(8);

        EditorGUILayout.BeginHorizontal();
        _self.logging = EditorGUILayout.Toggle("Logging", _self.logging);
        GUILayout.Space(12);
        _self.StartAutomatically = EditorGUILayout.Toggle("Start Session Automatically", _self.StartAutomatically);
        EditorGUILayout.EndHorizontal();

        GUILayout.Space(16);

        bool oldEditorSession     = _self.editorSessions;
        bool oldStandaloneSession = _self.standaloneSessions;

        EditorGUILayout.BeginHorizontal();
        _self.editorSessions = EditorGUILayout.Toggle("Start Fuse in Editor", _self.editorSessions);
        GUILayout.Space(12);
        _self.standaloneSessions = EditorGUILayout.Toggle("Start Fuse in Standalone", _self.standaloneSessions);
        EditorGUILayout.EndHorizontal();

        GUILayout.Space(16);

        bool oldAndroidIAB     = _self.androidIAB;
        bool oldandroidUnibill = _self.androidUnibill;
        bool oldiosStoreKit    = _self.iosStoreKit;
        bool oldiosUnibill     = _self.iosUnibill;
        bool oldSoomlaStore    = _self.soomlaStore;


        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.BeginVertical();
        GUI.enabled      = _p31Android || _self.androidIAB;
        _self.androidIAB = EditorGUILayout.Toggle("Android Prime31 Billing", _self.androidIAB);

        GUI.enabled          = _unibill || _self.androidUnibill;
        _self.androidUnibill = EditorGUILayout.Toggle("Android Unibill Billing", _self.androidUnibill);
        EditorGUILayout.EndVertical();

        GUILayout.Space(12);

        EditorGUILayout.BeginVertical();
        GUI.enabled       = _p31iOS || _self.iosStoreKit;
        _self.iosStoreKit = EditorGUILayout.Toggle("iOS Prime31 Billing", _self.iosStoreKit);

        GUI.enabled      = _unibill || _self.iosUnibill;
        _self.iosUnibill = EditorGUILayout.Toggle("iOS Unibill Billing", _self.iosUnibill);
        EditorGUILayout.EndVertical();

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();

        GUI.enabled       = _soomla || _self.soomlaStore;
        _self.soomlaStore = EditorGUILayout.Toggle("Soomla Store", _self.soomlaStore);

        EditorGUILayout.EndHorizontal();

        GUI.enabled = true;

        CheckToggle(_self.editorSessions, oldEditorSession, EditorUserBuildSettings.selectedBuildTargetGroup, "FUSE_SESSION_IN_EDITOR");
        CheckToggle(_self.editorSessions, oldEditorSession, BuildTargetGroup.Standalone, "FUSE_SESSION_IN_EDITOR");
        CheckToggle(_self.standaloneSessions, oldStandaloneSession, BuildTargetGroup.Standalone, "FUSE_SESSION_IN_STANDALONE");

        CheckToggle(_self.editorSessions, oldEditorSession, BuildTargetGroup.Android, "FUSE_SESSION_IN_EDITOR");
        CheckToggle(_self.androidIAB, oldAndroidIAB, BuildTargetGroup.Android, "USING_PRIME31_ANDROID");
        CheckToggle(_self.androidUnibill, oldandroidUnibill, BuildTargetGroup.Android, "USING_UNIBILL_ANDROID");
        CheckToggle(_self.soomlaStore, oldSoomlaStore, BuildTargetGroup.Android, "USING_SOOMLA_IAP");

        CheckToggle(_self.editorSessions, oldEditorSession, BuildTargetGroup.iOS, "FUSE_SESSION_IN_EDITOR");
        CheckToggle(_self.iosStoreKit, oldiosStoreKit, BuildTargetGroup.iOS, "USING_PRIME31_IOS");
        CheckToggle(_self.iosUnibill, oldiosUnibill, BuildTargetGroup.iOS, "USING_UNIBILL_IOS");
        CheckToggle(_self.soomlaStore, oldSoomlaStore, BuildTargetGroup.iOS, "USING_SOOMLA_IAP");

        GUILayout.Space(4);

        if (iconFoldout = EditorGUILayout.Foldout(iconFoldout, "Android notification icon"))
        {
            if (_icon == null)
            {
                _icon = new Texture2D(ICON_WIDTH, ICON_HEIGHT);
                _icon.LoadImage(File.ReadAllBytes(Application.dataPath + ICON_PATH));
            }

            GUILayout.Space(10);

            if (GUILayout.Button("Click to select icon:", EditorStyles.label))
            {
                _newIconPath = EditorUtility.OpenFilePanel("Choose icon", Application.dataPath, "png");
            }

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(_icon, EditorStyles.objectFieldThumb, GUILayout.Height(75), GUILayout.Width(75)))
            {
                _newIconPath = EditorUtility.OpenFilePanel("Choose icon", Application.dataPath, "png");
            }

            if (_error == null)
            {
                EditorGUILayout.HelpBox("Your texture must be " + ICON_WIDTH + "x" + ICON_HEIGHT + " pixels", MessageType.None);
            }
            else
            {
                EditorGUILayout.HelpBox(_error, MessageType.Error);
            }

            GUILayout.EndHorizontal();

            if (!string.IsNullOrEmpty(_newIconPath) && _newIconPath != (Application.dataPath + ICON_PATH))
            {
                UpdateIcon();
            }
            else
            {
                _newIconPath = null;
                _error       = null;
            }
        }
        else if (_icon != null)
        {
            DestroyImmediate(_icon);
            _icon = null;
        }

        GUILayout.Space(8);

        bool oldCoarse = androidPermissionCoarseLocation;
        bool oldFine   = androidPermissionFineLocation;

        Color oldColor = GUI.color;
        EditorGUILayout.LabelField("Android Permissions:");

        if (!androidPermissionCoarseLocation || !androidPermissionFineLocation)
        {
            EditorGUILayout.HelpBox("Location permissions are HIGHLY RECOMMENDED for optimal revenue.", MessageType.Warning);
        }

        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(12);
        GUI.color = androidPermissionCoarseLocation ? oldColor : Color.red;
        androidPermissionCoarseLocation = EditorGUILayout.Toggle("Coarse Location", androidPermissionCoarseLocation);
        GUI.color = androidPermissionFineLocation ? oldColor : Color.red;
        androidPermissionFineLocation = EditorGUILayout.Toggle("Fine Location", androidPermissionFineLocation);
        EditorGUILayout.EndHorizontal();

        GUILayout.Space(6);
        GUI.color = oldColor;

        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(12);

        EditorGUILayout.LabelField("Required Permissions", EditorStyles.helpBox);

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUI.enabled = false;
        GUILayout.Space(12);
        EditorGUILayout.Toggle("Write External Storage", true);
        EditorGUILayout.Toggle("Internet Access", true);
        GUI.enabled = true;
        EditorGUILayout.EndHorizontal();

        GUI.color = oldColor;

        GUILayout.Space(4);

        GUILayout.BeginVertical();

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Open Preferences"))
        {
            FuseSDKPrefs.Init();
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.EndVertical();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }

        if (oldCoarse != androidPermissionCoarseLocation || oldFine != androidPermissionFineLocation)
        {
            UpdateAndroidManifest();
        }
    }
Ejemplo n.º 22
0
    public override void OnInspectorGUI()
    {
        MegaModifyObject mod = (MegaModifyObject)target;

        MegaModifiers.GlobalDisplay = EditorGUILayout.Toggle("GlobalDisplayGizmos", MegaModifiers.GlobalDisplay);
        mod.Enabled     = EditorGUILayout.Toggle("Enabled", mod.Enabled);
        mod.recalcnorms = EditorGUILayout.Toggle("Recalc Normals", mod.recalcnorms);
        MegaNormalMethod method = mod.NormalMethod;

        mod.NormalMethod   = (MegaNormalMethod)EditorGUILayout.EnumPopup("Normal Method", mod.NormalMethod);
        mod.recalcbounds   = EditorGUILayout.Toggle("Recalc Bounds", mod.recalcbounds);
        mod.recalcCollider = EditorGUILayout.Toggle("Recalc Collider", mod.recalcCollider);
        mod.recalcTangents = EditorGUILayout.Toggle("Recalc Tangents", mod.recalcTangents);
        //mod.DoLateUpdate	= EditorGUILayout.Toggle("Do Late Update", mod.DoLateUpdate);
        mod.UpdateMode      = (MegaUpdateMode)EditorGUILayout.EnumPopup("Update Mode", mod.UpdateMode);
        mod.InvisibleUpdate = EditorGUILayout.Toggle("Invisible Update", mod.InvisibleUpdate);
        bool dynamicMesh = EditorGUILayout.Toggle("Dynamic Mesh", mod.dynamicMesh);

        if (dynamicMesh != mod.dynamicMesh)
        {
            mod.dynamicMesh = dynamicMesh;
            mod.GetMesh(true);
        }
        //mod.GrabVerts		= EditorGUILayout.Toggle("Grab Verts", mod.GrabVerts);
        mod.DrawGizmos = EditorGUILayout.Toggle("Draw Gizmos", mod.DrawGizmos);

        if (mod.NormalMethod != method && mod.NormalMethod == MegaNormalMethod.Mega)
        {
            mod.BuildNormalMapping(mod.mesh, false);
        }

        //showmulti = EditorGUILayout.Foldout(showmulti, "Multi Core");
#if !UNITY_FLASH && !UNITY_METRO && !UNITY_WP8
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Copy Object"))
        {
            GameObject obj = MegaCopyObject.DoCopyObjects(mod.gameObject);
            if (obj)
            {
                obj.transform.position = mod.gameObject.transform.position;

                Selection.activeGameObject = obj;
            }
        }

        if (GUILayout.Button("Copy Hierarchy"))
        {
            GameObject obj = MegaCopyObject.DoCopyObjectsChildren(mod.gameObject);
            Selection.activeGameObject = obj;
        }

        EditorGUILayout.EndHorizontal();
#endif
        if (GUILayout.Button("Threading Options"))
        {
            showmulti = !showmulti;
        }

        if (showmulti)
        {
            MegaModifiers.ThreadingOn = EditorGUILayout.Toggle("Threading Enabled", MegaModifiers.ThreadingOn);
            mod.UseThreading          = EditorGUILayout.Toggle("Thread This Object", mod.UseThreading);
        }

#if !UNITY_5 && !UNITY_2017 && !UNITY_2018 && !UNITY_2019 && !UNITY_2020
        EditorGUIUtility.LookLikeControls();
#endif

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }

        showorder = EditorGUILayout.Foldout(showorder, "Modifier Order");

        if (showorder && mod.mods != null)
        {
            for (int i = 0; i < mod.mods.Length; i++)
            {
                EditorGUILayout.BeginHorizontal("box");
                EditorGUILayout.LabelField("", i.ToString() + " - " + mod.mods[i].ModName() + " " + mod.mods[i].Order + " MaxLOD: " + mod.mods[i].MaxLOD);
                if (mod.mods[i].Label != "")
                {
                    EditorGUILayout.LabelField("\t" + mod.mods[i].Label);
                }
#if false
                if (i > 0)
                {
                    if (GUILayout.Button("Up", GUILayout.Width(40)))
                    {
                        MegaModifier m = mod.mods[i - 1];
                        mod.mods[i - 1] = mod.mods[i];
                        mod.mods[i]     = m;
                    }
                }

                if (i < mod.mods.Length - 1)
                {
                    if (GUILayout.Button("Down", GUILayout.Width(40)))
                    {
                        MegaModifier m = mod.mods[i + 1];
                        mod.mods[i + 1] = mod.mods[i];
                        mod.mods[i]     = m;
                    }
                }
#endif
                EditorGUILayout.EndHorizontal();
            }
        }

        // Group stuff
        if (GUILayout.Button("Group Members"))
        {
            showgroups = !showgroups;
        }

        if (showgroups)
        {
            //if ( GUILayout.Button("Add Object") )
            //{
            //MegaModifierTarget targ = new MegaModifierTarget();
            //	mod.group.Add(targ);
            //}

            for (int i = 0; i < mod.group.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                mod.group[i] = (GameObject)EditorGUILayout.ObjectField("Obj " + i, mod.group[i], typeof(GameObject), true);
                if (GUILayout.Button("Del"))
                {
                    mod.group.Remove(mod.group[i]);
                    i--;
                }
                EditorGUILayout.EndHorizontal();
            }

            GameObject newobj = (GameObject)EditorGUILayout.ObjectField("Add", null, typeof(GameObject), true);
            if (newobj)
            {
                mod.group.Add(newobj);
            }

            if (GUILayout.Button("Update"))
            {
                // for each group member check if it has a modify object comp, if not add one and copy values over
                // calculate box for all meshes and set, and set the Offset for each one
                // then for each modifier attached find or add and set instance value
                // in theory each gizmo should overlap the others

                // Have a method to update box and offsets if we allow moving in the group
            }
        }

        //if ( GUILayout.Button("Create Copy") )
        //{
        //	CloneObject();
        //}
    }
Ejemplo n.º 23
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();


            if (!initialized)
            {
                for (var i = 0; i < length; i++)
                {
                    var fold = Attribute.GetCustomAttribute(objectFields[i], typeof(FoldoutAttribute)) as FoldoutAttribute;

                    Cache c;
                    if (fold == null)
                    {
                        if (prevFold != null && prevFold.foldEverything)
                        {
                            if (!cache.TryGetValue(prevFold.name, out c))
                            {
                                cache.Add(prevFold.name, new Cache {
                                    atr = prevFold, types = new HashSet <string> {
                                        objectFields[i].Name
                                    }
                                });
                            }
                            else
                            {
                                c.types.Add(objectFields[i].Name);
                            }
                        }

                        continue;
                    }

                    prevFold = fold;
                    if (!cache.TryGetValue(fold.name, out c))
                    {
                        cache.Add(fold.name, new Cache {
                            atr = fold, types = new HashSet <string> {
                                objectFields[i].Name
                            }
                        });
                    }
                    else
                    {
                        c.types.Add(objectFields[i].Name);
                    }
                }


                var property = serializedObject.GetIterator();
                var next     = property.NextVisible(true);
                if (next)
                {
                    do
                    {
                        HandleProp(property);
                    } while (property.NextVisible(false));
                }
            }


            if (props.Count == 0)
            {
                DrawDefaultInspector();
                return;
            }

            initialized = true;

            using (new EditorGUI.DisabledScope("m_Script" == props[0].propertyPath))
            {
                EditorGUILayout.PropertyField(props[0], true);
            }

            EditorGUILayout.Space();

            foreach (var pair in cache)
            {
                var rect = EditorGUILayout.BeginVertical();

                EditorGUILayout.Space();

                EditorGUI.DrawRect(new Rect(rect.x - 1, rect.y - 1, rect.width + 1, rect.height + 1),
                                   colors.col0);

                EditorGUI.DrawRect(new Rect(rect.x - 1, rect.y - 1, rect.width + 1, rect.height + 1), colors.col1);


                pair.Value.expanded = EditorGUILayout.Foldout(pair.Value.expanded, pair.Value.atr.name, true,
                                                              style != null ? style : EditorStyles.foldout);


                EditorGUILayout.EndVertical();

                rect = EditorGUILayout.BeginVertical();

                EditorGUI.DrawRect(new Rect(rect.x - 1, rect.y - 1, rect.width + 1, rect.height + 1),
                                   colors.col2);

                if (pair.Value.expanded)
                {
                    EditorGUILayout.Space();
                    {
                        for (int i = 0; i < pair.Value.props.Count; i++)
                        {
                            EditorGUI.indentLevel = 1;

                            EditorGUILayout.PropertyField(pair.Value.props[i],
                                                          new GUIContent(pair.Value.props[i].name.FirstLetterToUpperCase()), true);
                            if (i == pair.Value.props.Count - 1)
                            {
                                EditorGUILayout.Space();
                            }
                        }
                    }
                }

                EditorGUI.indentLevel = 0;
                EditorGUILayout.EndVertical();
                EditorGUILayout.Space();
            }


            for (var i = 1; i < props.Count; i++)
            {
                EditorGUILayout.PropertyField(props[i], true);
            }


            serializedObject.ApplyModifiedProperties();
            EditorGUILayout.Space();
        }
        public void drawTabAddObjectsToBakers()
        {
            if (helpBoxString == null)
            {
                helpBoxString = "";
            }
            EditorGUILayout.HelpBox("To add, select one or more objects in the hierarchy view. Child Game Objects with MeshRender or SkinnedMeshRenderer will be added. Use the fields below to filter what is added." +
                                    "To remove, use the fields below to filter what is removed.\n" + helpBoxString, UnityEditor.MessageType.None);
            target = (MB3_MeshBakerRoot)EditorGUILayout.ObjectField("Target to add objects to", target, typeof(MB3_MeshBakerRoot), true);

            if (target != null)
            {
                targetGO = target.gameObject;
            }
            else
            {
                targetGO = null;
            }

            if (targetGO != oldTargetGO && targetGO != null)
            {
                textureBaker = targetGO.GetComponent <MB3_TextureBaker>();
                meshBaker    = targetGO.GetComponent <MB3_MeshBaker>();
                tbe          = new MB3_TextureBakerEditorInternal();
                mbe          = new MB3_MeshBakerEditorInternal();
                oldTargetGO  = targetGO;
                if (textureBaker != null)
                {
                    serializedObject = new SerializedObject(textureBaker);
                    tbe.OnEnable(serializedObject);
                }
                else if (meshBaker != null)
                {
                    serializedObject = new SerializedObject(meshBaker);
                    mbe.OnEnable(serializedObject);
                }
            }


            EditorGUIUtility.labelWidth = 300;
            onlyStaticObjects           = EditorGUILayout.Toggle("Only Static Objects", onlyStaticObjects);

            onlyEnabledObjects = EditorGUILayout.Toggle("Only Enabled Objects", onlyEnabledObjects);

            excludeMeshesWithOBuvs = EditorGUILayout.Toggle("Exclude meshes with out-of-bounds UVs", excludeMeshesWithOBuvs);

            excludeMeshesAlreadyAddedToBakers = EditorGUILayout.Toggle("Exclude GameObjects already added to bakers", excludeMeshesAlreadyAddedToBakers);

            lodLevelToInclude = EditorGUILayout.IntPopup("Only include objects on LOD Level", lodLevelToInclude, LODLevelLabels, LODLevelValues);

            mat       = (Material)EditorGUILayout.ObjectField("Using Material", mat, typeof(Material), true);
            shaderMat = (Material)EditorGUILayout.ObjectField("Using Shader", shaderMat, typeof(Material), true);

            string[] lightmapDisplayValues = new string[257];
            int[]    lightmapValues        = new int[257];
            lightmapValues[0]        = -2;
            lightmapValues[1]        = -1;
            lightmapDisplayValues[0] = "don't filter on lightmapping";
            lightmapDisplayValues[1] = "not lightmapped";
            for (int i = 2; i < lightmapDisplayValues.Length; i++)
            {
                lightmapDisplayValues[i] = "" + i;
                lightmapValues[i]        = i;
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Using Lightmap Index ");
            lightmapIndex = EditorGUILayout.IntPopup(lightmapIndex,
                                                     lightmapDisplayValues,
                                                     lightmapValues);
            EditorGUILayout.EndHorizontal();
            if (regExParseError != null && regExParseError.Length > 0)
            {
                EditorGUILayout.HelpBox("Error In Regular Expression:\n" + regExParseError, MessageType.Error);
            }
            searchRegEx = EditorGUILayout.TextField(GUIContentRegExpression, searchRegEx);


            EditorGUILayout.Separator();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Selected Meshes To Target"))
            {
                addSelectedObjects();
            }
            if (GUILayout.Button("Remove Matching Meshes From Target"))
            {
                removeSelectedObjects();
            }
            EditorGUILayout.EndHorizontal();

            if (textureBaker != null)
            {
                MB_EditorUtil.DrawSeparator();
                tbFoldout = EditorGUILayout.Foldout(tbFoldout, "Texture Baker");
                if (tbFoldout)
                {
                    if (targs == null)
                    {
                        targs = new UnityEngine.Object[1];
                    }
                    targs[0] = textureBaker;
                    tbe.DrawGUI(serializedObject, (MB3_TextureBaker)textureBaker, targs, typeof(MB3_MeshBakerEditorWindow));
                }
            }
            if (meshBaker != null)
            {
                MB_EditorUtil.DrawSeparator();
                mbFoldout = EditorGUILayout.Foldout(mbFoldout, "Mesh Baker");
                if (mbFoldout)
                {
                    if (targs == null)
                    {
                        targs = new UnityEngine.Object[1];
                    }
                    targs[0] = meshBaker;
                    mbe.DrawGUI(serializedObject, (MB3_MeshBaker)meshBaker, targs, typeof(MB3_MeshBakerEditorWindow));
                }
            }
        }
Ejemplo n.º 25
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector(); //Draws what you'd normally see in the inspector in absence of a custom inspector.

        if (GUI.changed)
        {
            restartneeded = CheckChange();
        }

        if (Application.isPlaying && manager.IsZEDReady && restartneeded) //Checks if we need to restart the camera.
        {
            GUILayout.Space(10);

            GUIStyle orangetext = new GUIStyle(EditorStyles.label);
            orangetext.normal.textColor = Color.red;
            orangetext.wordWrap         = true;

            string labeltext = "Settings have changed that require restarting the camera to apply.";
            Rect   labelrect = GUILayoutUtility.GetRect(new GUIContent(labeltext, ""), orangetext);
            EditorGUI.LabelField(labelrect, labeltext, orangetext);


            if (GUILayout.Button("Restart Camera"))
            {
                manager.Reset(); //Reset the ZED.

                //Reset the fields now that they're synced.
                resolution        = manager.resolution;
                depthmode         = manager.depthMode;
                usespatialmemory  = manager.enableSpatialMemory;
                usepostprocessing = manager.postProcessing;

                restartneeded = false;
            }
        }


        //Advanced Settings.
        GUILayout.Space(10);
        GUIStyle boldfoldout = new GUIStyle(EditorStyles.foldout);

        boldfoldout.fontStyle  = FontStyle.Bold;
        showadvanced.boolValue = EditorGUILayout.Foldout(showadvanced.boolValue, "Advanced Settings", boldfoldout);
        if (showadvanced.boolValue)
        {
            EditorGUI.indentLevel++;

            GUILayout.Space(5);
            EditorGUILayout.LabelField("ZED Plugin Layers", EditorStyles.boldLabel);

            //Style for the number boxes.
            GUIStyle layerboxstyle = new GUIStyle(EditorStyles.numberField);
            layerboxstyle.fixedWidth   = 0;
            layerboxstyle.stretchWidth = false;
            layerboxstyle.alignment    = TextAnchor.MiddleCenter;

            GUIStyle layerboxstyleerror = new GUIStyle(layerboxstyle);
            layerboxstyleerror.normal.textColor = new Color(.8f, 0, 0); //Red color if number is invalid.


            GUIContent lefteyelayerlabel = new GUIContent("Left Eye Layer", "Layer that the left canvas GameObject " +
                                                          "(showing the image from the left eye) is set to. The right camera in ZED_Rig_Stereo can't see this layer.");
            lefteyelayer.intValue = EditorGUILayout.IntField(lefteyelayerlabel, manager.leftEyeLayer,
                                                             lefteyelayer.intValue < 32 ? layerboxstyle : layerboxstyleerror);

            GUIContent righteyelayerlabel = new GUIContent("Right Eye Layer", "Layer that the right canvas GameObject " +
                                                           "(showing the image from the right eye) is set to. The left camera in ZED_Rig_Stereo can't see this layer.");
            righteyelayer.intValue = EditorGUILayout.IntField(righteyelayerlabel, manager.rightEyeLayer,
                                                              righteyelayer.intValue < 32 ? layerboxstyle : layerboxstyleerror);

            //Cache current final layers in case we need to unhide their old layers.
            int oldleftfinal  = manager.leftEyeLayerFinal;
            int oldrightfinal = manager.rightEyeLayerFinal;

            GUIContent lefteyefinallayerlabel = new GUIContent("Final Left Eye Layer", "Layer that the final left image canvas "
                                                               + "in the hidden AR rig is set to. Hidden from all ZED cameras except the final left camera.");
            lefteyelayerfinal.intValue = EditorGUILayout.IntField(lefteyefinallayerlabel, manager.leftEyeLayerFinal,
                                                                  lefteyelayerfinal.intValue < 32 ? layerboxstyle : layerboxstyleerror);

            GUIContent righteyefinallayerlabel = new GUIContent("Final Right Eye Layer", "Layer that the final right image canvas "
                                                                + "in the hidden AR rig is set to. Hidden from all ZED cameras except the final right camera.");
            righteyelayerfinal.intValue = EditorGUILayout.IntField(righteyefinallayerlabel, manager.rightEyeLayerFinal,
                                                                   righteyelayerfinal.intValue < 32 ? layerboxstyle : layerboxstyleerror);

            //If either final eye layer changed, make sure the old layer is made visible.
            if (oldleftfinal != lefteyelayerfinal.intValue)
            {
                Tools.visibleLayers |= (1 << oldleftfinal);
                if (manager.showARRig)
                {
                    Tools.visibleLayers |= (1 << lefteyelayerfinal.intValue);
                }
                else
                {
                    Tools.visibleLayers &= ~(1 << lefteyelayerfinal.intValue);
                }
            }
            if (oldrightfinal != righteyelayerfinal.intValue)
            {
                Tools.visibleLayers |= (1 << oldrightfinal);
                if (manager.showARRig)
                {
                    Tools.visibleLayers |= (1 << righteyelayerfinal.intValue);
                }
                else
                {
                    Tools.visibleLayers &= ~(1 << righteyelayerfinal.intValue);
                }
            }

            //Show small error message if any of the above values are too big.
            if (lefteyelayer.intValue > 31 || righteyelayer.intValue > 31 || lefteyelayerfinal.intValue > 31 || righteyelayerfinal.intValue > 31)
            {
                GUIStyle errormessagestyle = new GUIStyle(EditorStyles.label);
                errormessagestyle.normal.textColor = layerboxstyleerror.normal.textColor;
                errormessagestyle.wordWrap         = true;
                errormessagestyle.fontSize         = 10;

                string errortext = "Unity doesn't support layers above 31.";
                Rect   labelrect = GUILayoutUtility.GetRect(new GUIContent(errortext, ""), errormessagestyle);
                EditorGUI.LabelField(labelrect, errortext, errormessagestyle);
            }


            GUILayout.Space(7);

            EditorGUILayout.LabelField("Miscellaneous", EditorStyles.boldLabel);

            //Show AR Rig toggle.
            GUIContent showarlabel = new GUIContent("Show Final AR Rig", "Whether to show the hidden camera rig used in stereo AR mode to " +
                                                    "prepare images for HMD output. You normally shouldn't tamper with this rig, but seeing it can be useful for " +
                                                    "understanding how the ZED output works.");
            bool lastshowar = manager.showARRig;
            showarrig.boolValue = EditorGUILayout.Toggle(showarlabel, manager.showARRig);

            if (showarrig.boolValue != lastshowar)
            {
                LayerMask arlayers = (1 << manager.leftEyeLayerFinal);
                arlayers |= (1 << manager.rightEyeLayerFinal);

                if (showarrig.boolValue == true)
                {
                    Tools.visibleLayers |= arlayers;
                }
                else
                {
                    Tools.visibleLayers &= ~(arlayers);
                }

                if (manager.zedRigDisplayer != null && Application.isPlaying)
                {
                    manager.zedRigDisplayer.hideFlags = showarrig.boolValue ? HideFlags.None : HideFlags.HideAndDontSave;
                }
            }

            //Fade In At Start toggle.
            GUIContent fadeinlabel = new GUIContent("Fade In At Start", "When enabled, makes the ZED image fade in from black when the application starts.");
            fadeinonstart.boolValue = EditorGUILayout.Toggle(fadeinlabel, manager.fadeInOnStart);

            //Don't Destroy On Load toggle.
            GUIContent dontdestroylable = new GUIContent("Don't Destroy on Load", "When enabled, applies DontDestroyOnLoad() on the ZED rig in Awake(), " +
                                                         "preserving it between scene transitions.");
            dontdestroyonload.boolValue = EditorGUILayout.Toggle(dontdestroylable, manager.dontDestroyOnLoad);

            EditorGUI.indentLevel--;
        }
        serializedObject.ApplyModifiedProperties();

        //Status window.
        GUIStyle standardStyle = new GUIStyle(EditorStyles.textField);
        GUIStyle errorStyle    = new GUIStyle(EditorStyles.textField);

        errorStyle.normal.textColor = Color.red;


        GUILayout.Space(10);
        EditorGUILayout.LabelField("Status", EditorStyles.boldLabel);
        EditorGUI.BeginDisabledGroup(true);

        GUIContent sdkversionlabel = new GUIContent("SDK Version:", "Version of the installed ZED SDK.");

        EditorGUILayout.TextField(sdkversionlabel, manager.versionZED);

        GUIContent enginefpslabel = new GUIContent("Engine FPS:", "How many frames per second the engine is rendering.");

        EditorGUILayout.TextField(enginefpslabel, manager.engineFPS);

        GUIContent camerafpslabel = new GUIContent("Camera FPS:", "How many images per second are received from the ZED.");

        EditorGUILayout.TextField(camerafpslabel, manager.cameraFPS);

        GUIContent trackingstatelabel = new GUIContent("Tracking State:", "Whether the ZED's tracking is on, off, or searching (lost position, trying to recover).");

        if (manager.IsCameraTracked || !manager.IsZEDReady)
        {
            EditorGUILayout.TextField(trackingstatelabel, manager.trackingState, standardStyle);
        }
        else
        {
            EditorGUILayout.TextField(trackingstatelabel, manager.trackingState, errorStyle);
        }

        GUIContent hmdlabel = new GUIContent("HMD Device:", "The connected VR headset, if any.");

        if (Application.isPlaying)
        {
            EditorGUILayout.TextField(hmdlabel, manager.HMDDevice);
        }
        else
        {
            //Detect devices through USB.
            if (sl.ZEDCamera.CheckUSBDeviceConnected(sl.USB_DEVICE.USB_DEVICE_OCULUS))
            {
                EditorGUILayout.TextField(hmdlabel, "Oculus USB Detected");
            }
            else if (sl.ZEDCamera.CheckUSBDeviceConnected(sl.USB_DEVICE.USB_DEVICE_HTC))
            {
                EditorGUILayout.TextField(hmdlabel, "HTC USB Detected");
            }
            else
            {
                EditorGUILayout.TextField(hmdlabel, "-");
            }
        }
        EditorGUI.EndDisabledGroup();

        GUILayout.Space(20);
        GUIContent camcontrolbuttonlabel = new GUIContent("Open Camera Control", "Opens a window for adjusting camera settings like brightness, gain/exposure, etc.");

        if (GUILayout.Button(camcontrolbuttonlabel))
        {
            EditorWindow.GetWindow(typeof(ZEDCameraSettingsEditor), false, "ZED Camera").Show();
        }
    }
        private void OnGUI()
        {
            GUI.skin.label.richText = true;
            GUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();

            GameObject prefab = EditorGUILayout.ObjectField("Asset to Generate", generatedPrefab, typeof(GameObject), true) as GameObject;

            if (prefab != generatedPrefab)
            {
                generateAnims.Clear();
                customClips.Clear();
                generatedPrefab = prefab;

                SkinnedMeshRenderer[] meshRender = generatedPrefab.GetComponentsInChildren <SkinnedMeshRenderer>();
                List <Matrix4x4>      bindPose   = new List <Matrix4x4>(150);
                boneTransform = RuntimeHelper.MergeBone(meshRender, bindPose);
            }

            bool error = false;

            if (generatedPrefab)
            {
                exposeAttachments = EditorGUILayout.Toggle("Enable Attachments", exposeAttachments);
                if (exposeAttachments)
                {
                    showAttachmentSetting = EditorGUILayout.Foldout(showAttachmentSetting, "Attachment setting");
                    if (showAttachmentSetting)
                    {
                        EditorGUI.BeginChangeCheck();
                        GameObject fbx = EditorGUILayout.ObjectField("FBX refrenced by Prefab:", generatedFbx, typeof(GameObject), false) as GameObject;
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (fbx != generatedFbx)
                            {
                                SkinnedMeshRenderer[] meshRender = generatedPrefab.GetComponentsInChildren <SkinnedMeshRenderer>();
                                List <Matrix4x4>      bindPose   = new List <Matrix4x4>(150);
                                boneTransform = RuntimeHelper.MergeBone(meshRender, bindPose);

                                generatedFbx = fbx;
                                var allTrans = generatedPrefab.GetComponentsInChildren <Transform>().ToList();
                                allTrans.RemoveAll(q => boneTransform.Contains(q));

                                //var allTrans = boneTransform;
                                selectExtraBone.Clear();
                                for (int i = 0; i != allTrans.Count; ++i)
                                {
                                    selectExtraBone.Add(allTrans[i].name, false);
                                }
                            }
                            else if (fbx == null)
                            {
                                selectExtraBone.Clear();
                            }
                        }
                        if (selectExtraBone.Count > 0)
                        {
                            var temp = new Dictionary <string, bool>();
                            foreach (var obj in selectExtraBone)
                            {
                                temp[obj.Key] = obj.Value;
                            }
                            scrollPosition2 = GUILayout.BeginScrollView(scrollPosition2);
                            foreach (var obj in temp)
                            {
                                bool value = EditorGUILayout.Toggle(string.Format("   {0}", obj.Key), obj.Value);
                                selectExtraBone[obj.Key] = value;
                            }
                            GUILayout.EndScrollView();
                        }
                    }
                }
                else
                {
                    generatedFbx = null;
                }

                aniFps = EditorGUILayout.IntSlider("FPS", aniFps, 1, 120);

                Animator animator = generatedPrefab.GetComponentInChildren <Animator>();
                if (animator == null)
                {
                    EditorGUILayout.LabelField("Error: The prefab should have a Animator Component.");
                    return;
                }
                if (animator.runtimeAnimatorController == null)
                {
                    EditorGUILayout.LabelField("Error: The prefab's Animator should have a Animator Controller.");
                    return;
                }
                var        clips       = GetClips(animator);
                string[]   clipNames   = generateAnims.Keys.ToArray();
                int        totalFrames = 0;
                List <int> frames      = new List <int>();
                foreach (var clipName in clipNames)
                {
                    if (!generateAnims[clipName])
                    {
                        continue;
                    }

                    AnimationClip clip = clips.Find(delegate(AnimationClip c) {
                        if (c != null)
                        {
                            return(c.name == clipName);
                        }
                        return(false);
                    });
                    int framesToBake = clip ? (int)(clip.length * aniFps / 1.0f) : 1;
                    framesToBake = Mathf.Clamp(framesToBake, 1, framesToBake);
                    totalFrames += framesToBake;
                    frames.Add(framesToBake);
                }

                int textureCount = 1;
                int textureWidth = CalculateTextureSize(out textureCount, frames.ToArray(), boneTransform);
                error = textureCount == 0;
                if (textureCount == 0)
                {
                    EditorGUILayout.LabelField("Error: There is certain animation's frames which is larger than a whole texture.");
                }
                else if (textureCount == 1)
                {
                    EditorGUILayout.LabelField(string.Format("Animation Texture will be one {0} X {1} texture", textureWidth, textureWidth));
                }
                else
                {
                    EditorGUILayout.LabelField(string.Format("Animation Texture will be {2} 1024 X 1024 and one {0} X {1} textures", textureWidth, textureWidth, textureCount - 1));
                }

                scrollPosition = GUILayout.BeginScrollView(scrollPosition);
                foreach (var clipName in clipNames)
                {
                    AnimationClip clip = clips.Find(delegate(AnimationClip c) {
                        if (c != null)
                        {
                            return(c.name == clipName);
                        }
                        return(false);
                    });
                    int framesToBake = clip ? (int)(clip.length * aniFps / 1.0f) : 1;
                    framesToBake = Mathf.Clamp(framesToBake, 1, framesToBake);
                    GUILayout.BeginHorizontal();
                    {
                        generateAnims[clipName] = EditorGUILayout.Toggle(string.Format("({0}) {1} ", framesToBake, clipName), generateAnims[clipName]);
                        GUI.enabled             = generateAnims[clipName];
                        //frameSkips[clipName] = Mathf.Clamp(EditorGUILayout.IntField(frameSkips[clipName]), 1, fps);
                        GUI.enabled = true;
                    }
                    GUILayout.EndHorizontal();
                    if (framesToBake > 5000)
                    {
                        GUI.skin.label.richText = true;
                        EditorGUILayout.LabelField("<color=red>Long animations degrade performance, consider using a higher frame skip value.</color>", GUI.skin.label);
                    }
                }
                GUILayout.EndScrollView();
            }

            if (generatedPrefab && !error)
            {
                if (GUILayout.Button(string.Format("Generate")))
                {
                    //BakeAnimation();
                    BakeWithAnimator();
                }
            }
        }
        public override void OnInspectorGUI()
        {
            bool isInspectingPrefab = (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab);

            // Try to auto-assign SkeletonRenderer field.
            if (skeletonRenderer.objectReferenceValue == null)
            {
                var foundSkeletonRenderer = follower.GetComponentInParent <SkeletonRenderer>();
                if (foundSkeletonRenderer != null)
                {
                    Debug.Log("BoundingBoxFollower automatically assigned: " + foundSkeletonRenderer.gameObject.name);
                }
                else if (Event.current.type == EventType.Repaint)
                {
                    Debug.Log("No Spine GameObject detected. Make sure to set this GameObject as a child of the Spine GameObject; or set BoundingBoxFollower's 'Skeleton Renderer' field in the inspector.");
                }

                skeletonRenderer.objectReferenceValue = foundSkeletonRenderer;
                serializedObject.ApplyModifiedProperties();
            }

            var sr = skeletonRenderer.objectReferenceValue as SkeletonRenderer;

            if (sr != null && sr.gameObject == follower.gameObject)
            {
                using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) {
                    EditorGUILayout.HelpBox("It's ideal to add BoundingBoxFollower to a separate child GameObject of the Spine GameObject.", MessageType.Warning);

                    if (GUILayout.Button(new GUIContent("Move BoundingBoxFollower to new GameObject", Icons.boundingBox), GUILayout.Height(50f)))
                    {
                        AddBoundingBoxFollowerChild(sr, follower);
                        DestroyImmediate(follower);
                        return;
                    }
                }
                EditorGUILayout.Space();
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(skeletonRenderer);
            EditorGUILayout.PropertyField(slotName, new GUIContent("Slot"));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                if (!isInspectingPrefab)
                {
                    rebuildRequired = true;
                }
            }

            using (new SpineInspectorUtility.LabelWidthScope(150f)) {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(isTrigger);
                bool triggerChanged = EditorGUI.EndChangeCheck();

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(clearStateOnDisable, new GUIContent(clearStateOnDisable.displayName, "Enable this if you are pooling your Spine GameObject"));
                bool clearStateChanged = EditorGUI.EndChangeCheck();

                if (clearStateChanged || triggerChanged)
                {
                    serializedObject.ApplyModifiedProperties();
                    if (triggerChanged)
                    {
                        foreach (var col in follower.colliderTable.Values)
                        {
                            col.isTrigger = isTrigger.boolValue;
                        }
                    }
                }
            }

            if (isInspectingPrefab)
            {
                follower.colliderTable.Clear();
                follower.nameTable.Clear();
                EditorGUILayout.HelpBox("BoundingBoxAttachments cannot be previewed in prefabs.", MessageType.Info);

                // How do you prevent components from being saved into the prefab? No such HideFlag. DontSaveInEditor | DontSaveInBuild does not work. DestroyImmediate does not work.
                var collider = follower.GetComponent <PolygonCollider2D>();
                if (collider != null)
                {
                    Debug.LogWarning("Found BoundingBoxFollower collider components in prefab. These are disposed and regenerated at runtime.");
                }
            }
            else
            {
                using (new SpineInspectorUtility.BoxScope()) {
                    if (debugIsExpanded = EditorGUILayout.Foldout(debugIsExpanded, "Debug Colliders"))
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.LabelField(string.Format("Attachment Names ({0} PolygonCollider2D)", follower.colliderTable.Count));
                        EditorGUI.BeginChangeCheck();
                        foreach (var kp in follower.nameTable)
                        {
                            string attachmentName = kp.Value;
                            var    collider       = follower.colliderTable[kp.Key];
                            bool   isPlaceholder  = attachmentName != kp.Key.Name;
                            collider.enabled = EditorGUILayout.ToggleLeft(new GUIContent(!isPlaceholder ? attachmentName : string.Format("{0} [{1}]", attachmentName, kp.Key.Name), isPlaceholder ? Icons.skinPlaceholder : Icons.boundingBox), collider.enabled);
                        }
                        sceneRepaintRequired |= EditorGUI.EndChangeCheck();
                        EditorGUI.indentLevel--;
                    }
                }
            }

            bool hasBoneFollower = follower.GetComponent <BoneFollower>() != null;

            if (!hasBoneFollower)
            {
                bool buttonDisabled = follower.Slot == null;
                using (new EditorGUI.DisabledGroupScope(buttonDisabled)) {
                    addBoneFollower |= SpineInspectorUtility.LargeCenteredButton(AddBoneFollowerLabel, true);
                    EditorGUILayout.Space();
                }
            }


            if (Event.current.type == EventType.Repaint)
            {
                if (addBoneFollower)
                {
                    var boneFollower = follower.gameObject.AddComponent <BoneFollower>();
                    boneFollower.boneName = follower.Slot.Data.BoneData.Name;
                    addBoneFollower       = false;
                }

                if (sceneRepaintRequired)
                {
                    SceneView.RepaintAll();
                    sceneRepaintRequired = false;
                }

                if (rebuildRequired)
                {
                    follower.Initialize();
                    rebuildRequired = false;
                }
            }
        }
        private void drawProperties(SerializedProperty list)
        {
            List <EditorCurveBinding> bindings = null;

            foreach (var target in targets)
            {
                var parent        = target.transform.root.gameObject;
                var singleBinding = new List <EditorCurveBinding>(AnimationUtility.GetAnimatableBindings(target.gameObject, parent));
                if (bindings == null)
                {
                    bindings = new List <EditorCurveBinding>(singleBinding);
                }
                else
                {
                    for (int i = bindings.Count; i-- != 0;)
                    {
                        if (!singleBinding.Query().Any(t => t.propertyName == bindings[i].propertyName && t.type == bindings[i].type))
                        {
                            bindings.RemoveAt(i);
                        }
                    }
                }
            }

            bindings = bindings.Query().
                       Where(t => t.type != typeof(PropertyRecorder) &&
                             t.type != typeof(GameObject) &&
                             t.type != typeof(Transform) &&
                             t.propertyName != "m_Enabled").
                       ToList();

            bool shouldOverride = false;
            bool overrideValue  = false;
            Type currType       = null;

            EditorGUI.indentLevel++;

            foreach (var binding in bindings)
            {
                bool isTypeExpanded = targets.All(t => t.IsBindingExpanded(binding));

                if (binding.type != currType)
                {
                    currType       = binding.type;
                    shouldOverride = false;

                    EditorGUI.indentLevel--;
                    EditorGUILayout.BeginHorizontal();

                    isTypeExpanded = EditorGUILayout.Foldout(isTypeExpanded, binding.type.Name);
                    foreach (var target in targets)
                    {
                        target.SetBindingExpanded(binding, isTypeExpanded);
                    }

                    if (GUILayout.Button("Record All"))
                    {
                        shouldOverride = true;
                        overrideValue  = true;
                    }

                    if (GUILayout.Button("Clear All"))
                    {
                        shouldOverride = true;
                        overrideValue  = false;
                    }

                    EditorGUILayout.EndHorizontal();
                    EditorGUI.indentLevel++;
                }

                if (isTypeExpanded)
                {
                    EditorGUI.showMixedValue = !targets.Query().Select(t => t.IsBindingEnabled(binding)).AllEqual();
                    bool isEnabled = target.IsBindingEnabled(binding);

                    EditorGUI.BeginChangeCheck();
                    isEnabled = EditorGUILayout.ToggleLeft(binding.propertyName, isEnabled);

                    if (EditorGUI.EndChangeCheck())
                    {
                        foreach (var target in targets)
                        {
                            target.SetBindingEnabled(binding, isEnabled);
                        }
                    }
                }

                if (shouldOverride)
                {
                    foreach (var target in targets)
                    {
                        target.SetBindingEnabled(binding, overrideValue);
                    }
                }
            }

            EditorGUI.indentLevel--;

            serializedObject.Update();
        }
Ejemplo n.º 29
0
        protected override void OnInspectorRuntimeGUI()
        {
            base.OnInspectorRuntimeGUI();

            GUILayout.BeginHorizontal();
            Target.IsLockTemporaryUI = EditorGUILayout.Toggle("Lock Temporary", Target.IsLockTemporaryUI);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            _overlayUIFoldout = EditorGUILayout.Foldout(_overlayUIFoldout, "Overlay UIs", true);
            GUILayout.EndHorizontal();

            if (_overlayUIFoldout)
            {
                foreach (var ui in _UIHelper.OverlayUIs)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(20);
                    GUILayout.Label(ui.Key.Name);
                    GUILayout.FlexibleSpace();
                    GUILayout.Label((ui.Value.IsCreated ? "[Created]" : "[Uncreated]") + " " + (ui.Value.IsOpened ? "[Opened]" : "[Unopened]"));
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Space(40);
                    EditorGUILayout.ObjectField(ui.Value.UIEntity, typeof(GameObject), true);
                    if (ui.Value.IsCreated)
                    {
                        GUILayout.FlexibleSpace();
                        GUI.enabled = !ui.Value.IsOpened;
                        if (GUILayout.Button("Open", EditorStyles.miniButtonLeft, GUILayout.Width(45)))
                        {
                            if (ui.Key.IsSubclassOf(typeof(UILogicResident)))
                            {
                                Target.OpenResidentUI(ui.Key);
                            }
                            else if (ui.Key.IsSubclassOf(typeof(UILogicTemporary)))
                            {
                                Target.OpenTemporaryUI(ui.Key);
                            }
                        }
                        GUI.enabled = ui.Value.IsOpened;
                        if (GUILayout.Button("Close", EditorStyles.miniButtonRight, GUILayout.Width(45)))
                        {
                            Target.CloseUI(ui.Key);
                        }
                        GUI.enabled = true;
                    }
                    GUILayout.EndHorizontal();
                }
            }

            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            _cameraUIFoldout = EditorGUILayout.Foldout(_cameraUIFoldout, "Camera UIs", true);
            GUILayout.EndHorizontal();

            if (_cameraUIFoldout)
            {
                foreach (var ui in _UIHelper.CameraUIs)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(20);
                    GUILayout.Label(ui.Key.Name);
                    GUILayout.FlexibleSpace();
                    GUILayout.Label((ui.Value.IsCreated ? "[Created]" : "[Uncreated]") + " " + (ui.Value.IsOpened ? "[Opened]" : "[Unopened]"));
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Space(40);
                    EditorGUILayout.ObjectField(ui.Value.UIEntity, typeof(GameObject), true);
                    if (ui.Value.IsCreated)
                    {
                        GUILayout.FlexibleSpace();
                        GUI.enabled = !ui.Value.IsOpened;
                        if (GUILayout.Button("Open", EditorStyles.miniButtonLeft, GUILayout.Width(45)))
                        {
                            if (ui.Key.IsSubclassOf(typeof(UILogicResident)))
                            {
                                Target.OpenResidentUI(ui.Key);
                            }
                            else if (ui.Key.IsSubclassOf(typeof(UILogicTemporary)))
                            {
                                Target.OpenTemporaryUI(ui.Key);
                            }
                        }
                        GUI.enabled = ui.Value.IsOpened;
                        if (GUILayout.Button("Close", EditorStyles.miniButtonRight, GUILayout.Width(45)))
                        {
                            Target.CloseUI(ui.Key);
                        }
                        GUI.enabled = true;
                    }
                    GUILayout.EndHorizontal();
                }
            }
        }
Ejemplo n.º 30
0
    /// <summary>
    /// 依赖包视图
    /// </summary>
    void RelyPackagesView()
    {
        for (int i = 0; i < relyPackages.Count; i++)
        {
            relyPackages[i].relyPackagesMask = 1 << i;
            if (!GetIsShowByRelyMask(relyPackages[i]))
            {
                continue;
            }

            //标签头
            EditorGUI.indentLevel = 2;
            EditorGUILayout.BeginHorizontal();
            relyPackages[i].isFold = EditorGUILayout.Foldout(relyPackages[i].isFold, relyPackages[i].name);

            //删除按钮
            if (GUILayout.Button("删除"))
            {
                relyPackages.RemoveAt(i);
                continue;
            }

            EditorGUILayout.EndHorizontal();

            EditorGUI.indentLevel = 3;
            if (relyPackages[i].isFold)
            {
                //名称
                EditorGUI.indentLevel = 4;
                relyPackages[i].name  = EditorGUILayout.TextField("name:", relyPackages[i].name);

                //加载路径
                relyPackages[i].path = relyAssetsBundlePath + "/" + relyPackages[i].name;
                EditorGUILayout.LabelField("Path: ", relyPackages[i].path);

                //子资源视图
                relyPackages[i].isFold_objects = EditorGUILayout.Foldout(relyPackages[i].isFold_objects, "Objects");
                EditorGUI.indentLevel          = 5;
                if (relyPackages[i].isFold_objects)
                {
                    ObjectListView(relyPackages[i]);
                }
            }
            EditorGUI.indentLevel = 2;
            //消息视图
            MessageView(relyPackages[i]);
        }

        EditorGUILayout.Space();
        EditorGUI.indentLevel = 1;
        //EditorGUILayout.BeginHorizontal();
        //EditorGUILayout.LabelField("Button:");

        if (GUILayout.Button("增加一个依赖包"))
        {
            EditPackageConfig EditPackageConfigTmp = new EditPackageConfig();
            EditPackageConfigTmp.name = "NewRelyAssetsBundle" + relyPackages.Count;

            relyPackages.Add(EditPackageConfigTmp);
        }
        //EditorGUILayout.EndHorizontal();
    }