示例#1
0
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     _currentFilePath = EditorTools.SaveFileDialog(_currentFilePath, _storage, _loadedAsset);
     EditorTools.UpdateFormTitle("Emotional Decision Making", _currentFilePath, this);
 }
    override public void OnInspectorGUI()
    {
        EditorGUILayout.BeginHorizontal();
        EditorTools.DrawLabel("Method", true, GUILayout.Width(150f));
        tween.method = (Method)EditorGUILayout.EnumPopup(tween.method);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorTools.DrawLabel("Steeper curves", true, GUILayout.Width(150f));
        tween.steeperCurves = EditorGUILayout.Toggle(tween.steeperCurves);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorTools.DrawLabel("NotUsedForScreenAnimatingCondition", true, GUILayout.Width(150f));
        tween.NotUsedForScreenAnimatingCondition = EditorGUILayout.Toggle(tween.NotUsedForScreenAnimatingCondition);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorTools.DrawLabel("Style", true, GUILayout.Width(150f));
        tween.style = (Style)EditorGUILayout.EnumPopup(tween.style);
        EditorGUILayout.EndHorizontal();


        if (TweensCurves.Instance != null)
        {
            List <string> curves    = TweensCurves.Instance.IdList;
            string        currentId = tween.AnimationCurveId;
            int           index     = 0;

            if (curves.Exists(id => id.Equals(currentId)))
            {
                index = curves.IndexOf(currentId);
            }
            else
            {
                curves.Insert(index, currentId);
            }

            EditorGUILayout.BeginHorizontal();
            EditorTools.DrawLabel("Curve ID", true, GUILayout.Width(150f));
            int newIndex = EditorGUILayout.Popup(index, curves.ToArray());
            EditorGUILayout.EndHorizontal();

            if (newIndex != index)
            {
                tween.AnimationCurveId = curves[newIndex];
            }
        }

        EditorGUILayout.BeginHorizontal();
        EditorTools.DrawLabel("Curve", true, GUILayout.Width(150f));
        tween.useCurve       = EditorTools.DrawToggle(tween.useCurve, string.Empty, "Use curve", true, 15f);
        tween.animationCurve = EditorGUILayout.CurveField(tween.animationCurve);
        tween.animationCurve.RoundEdges();

        if (TweensCurves.Instance != null)
        {
            if (EditorTools.DrawButton("S", "Save at prefab (don't forget apply!)", true, 20f))
            {
                TweensCurves.Instance.AddCurve(tween.AnimationCurveId, tween.animationCurve);
            }
            if (EditorTools.DrawButton("U", "Update curve from prefab", true, 20f))
            {
                tween.AnimationCurveId = tween.AnimationCurveId;
            }
        }

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorTools.DrawLabel("Ignore time scale", true, GUILayout.Width(150f));
        tween.ignoreTimeScale = EditorGUILayout.Toggle(tween.ignoreTimeScale);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorTools.DrawLabel("Set Begin State At Start", true, GUILayout.Width(150f));
        tween.shouldSetBeginStateAtStart = EditorGUILayout.Toggle(tween.shouldSetBeginStateAtStart);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorTools.DrawLabel("Duration", true, GUILayout.Width(150f));
        const float defaultDuration = 1f;

        if (EditorTools.DrawButton(defaultDuration.ToString(), ("Set duration to " + defaultDuration), true, 20f))
        {
            tween.duration = defaultDuration;
        }
        tween.duration = EditorGUILayout.Slider(tween.duration, 0f, 10f);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorTools.DrawLabel("Scale duration", true, GUILayout.Width(150f));
        const float defaultScaleDuration = 1f;

        if (EditorTools.DrawButton(defaultScaleDuration.ToString(), ("Set scale duration to " + defaultScaleDuration), true, 20f))
        {
            tween.scaleDuration = defaultScaleDuration;
        }
        tween.scaleDuration = EditorGUILayout.Slider(tween.scaleDuration, 0f, 5f);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.PrefixLabel("Call when finished");
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Script");
        EditorGUILayout.LabelField("Call method");
        EditorGUILayout.EndHorizontal();
        EditorTools.DrawInvokeData(tween.invokeWhenFinished);
        Color defaultContentColor = GUI.contentColor;

        GUI.contentColor = Color.cyan;
        EditorGUILayout.LabelField("============================================================================================");
        GUI.contentColor = defaultContentColor;
        CustomInspectorGUI();
        GUI.contentColor = Color.cyan;
        EditorGUILayout.LabelField("============================================================================================");
        GUI.contentColor = defaultContentColor;
        if (Application.isPlaying)
        {
            DrawRunButtons(tween);
        }
        else
        {
            DrawStateSlider(tween);
        }
        EditorGUILayout.Space();
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
示例#3
0
        private static List <IssueRecord> CheckSceneForIssues(string scenePath)
        {
            List <GameObject> gameObjects = EditorTools.GetAllSuitableGameObjectsInCurrentScene();

            return(CheckObjectsForIssues(scenePath, gameObjects));
        }
示例#4
0
 protected override void DoSearchGUI()
 {
     string[] searchResult = EditorTools.SearchField(this.m_SearchString, searchFilter, searchFilters, GUILayout.Width(m_SidebarRect.width - 20));
     searchFilter   = searchResult[0];
     m_SearchString = searchResult[1];
 }
    protected override void CustomInspectorGUI()
    {
        var tTextureOffset = (TweenTextureOffset)tween;

        if (tTextureOffset.IsBeginStateSet)
        {
            GUI.contentColor = Color.green;
        }
        EditorGUILayout.LabelField("Begin offset");
        GUI.contentColor = defaultContentColor;
        EditorGUILayout.BeginHorizontal();
        if (EditorTools.DrawButton("R", "Reset offset to zero", IsResetOffsetValid(tTextureOffset.beginOffset), 20f))
        {
            EditorTools.RegisterUndo("Reset begin offset", tTextureOffset);
            tTextureOffset.beginOffset = Vector2.zero;
        }
        #if UNITY_5_4_OR_NEWER
        EditorGUIUtility.labelWidth = 15f;
        EditorGUIUtility.fieldWidth = 0;
        #else
        EditorGUIUtility.LookLikeControls(15f, 0);
        #endif
        tTextureOffset.beginOffset = EditorTools.DrawVector2(tTextureOffset.beginOffset);
        #if UNITY_5_4_OR_NEWER
        EditorGUIUtility.labelWidth = 0;
        EditorGUIUtility.fieldWidth = 0;
        #else
        EditorGUIUtility.LookLikeControls();
        #endif
        if (EditorTools.DrawButton("S", "Set current offset", IsSetOffsetValid(tTextureOffset.beginOffset, tTextureOffset.CurrentOffset), 20f))
        {
            EditorTools.RegisterUndo("Set begin offset", tTextureOffset);
            tTextureOffset.beginOffset = tTextureOffset.CurrentOffset;
        }
        EditorGUILayout.EndHorizontal();
        if (tTextureOffset.IsEndStateSet)
        {
            GUI.contentColor = Color.green;
        }
        EditorGUILayout.LabelField("End offset");
        GUI.contentColor = defaultContentColor;
        EditorGUILayout.BeginHorizontal();
        if (EditorTools.DrawButton("R", "Reset offset to zero", IsResetOffsetValid(tTextureOffset.endOffset), 20f))
        {
            EditorTools.RegisterUndo("Reset end offset", tTextureOffset);
            tTextureOffset.endOffset = Vector2.zero;
        }
        #if UNITY_5_4_OR_NEWER
        EditorGUIUtility.labelWidth = 15f;
        EditorGUIUtility.fieldWidth = 0;
        #else
        EditorGUIUtility.LookLikeControls(15f, 0);
        #endif
        tTextureOffset.endOffset = EditorTools.DrawVector2(tTextureOffset.endOffset);
        #if UNITY_5_4_OR_NEWER
        EditorGUIUtility.labelWidth = 0;
        EditorGUIUtility.fieldWidth = 0;
        #else
        EditorGUIUtility.LookLikeControls();
        #endif
        if (EditorTools.DrawButton("S", "Set current offset", IsSetOffsetValid(tTextureOffset.endOffset, tTextureOffset.CurrentOffset), 20f))
        {
            EditorTools.RegisterUndo("Set end offset", tTextureOffset);
            tTextureOffset.endOffset = tTextureOffset.CurrentOffset;
        }
        EditorGUILayout.EndHorizontal();
    }
示例#6
0
        private void OnGUI()
        {
            if (serializedObject == null)
            {
                serializedObject = new SerializedObject(target);
            }
            GUILayout.BeginVertical("grey_border");
            GUILayout.Space(6f);
            searchString = EditorTools.SearchField(searchString);


            GUIStyle header = new GUIStyle("In BigTitle")
            {
                font         = EditorStyles.boldLabel.font,
                stretchWidth = true,
            };

            SerializedProperty elements = serializedObject.FindProperty("items");

            string headerTitle = (selectedIndex != -1) ?(selectedÍtem != null?selectedÍtem.Name:"Null"): "Items";
            Rect   headerRect  = GUILayoutUtility.GetRect(new GUIContent(headerTitle), header);

            if (GUI.Button(headerRect, headerTitle, header))
            {
                selectedIndex = -1;
            }

            if (selectedIndex != -1)
            {
                GUIStyle leftArrow = new GUIStyle("AC LeftArrow");
                GUI.Label(new Rect(headerRect.x, headerRect.y + 4f, 16f, 16f), "", leftArrow);
                serializedObject.Update();
                SerializedProperty element = elements.GetArrayElementAtIndex(selectedIndex);
                DrawItemDefinition(element);
                selectedÍtem = (Item)element.FindPropertyRelative("item").objectReferenceValue;
                serializedObject.ApplyModifiedProperties();
                return;
            }
            GUILayout.Space(-5);
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);

            GUIStyle selectButton = new GUIStyle("MeTransitionSelectHead")
            {
                alignment = TextAnchor.MiddleLeft
            };

            selectButton.padding.left = 10;

            for (int i = 0; i < elements.arraySize; i++)
            {
                SerializedProperty element = elements.GetArrayElementAtIndex(i);
                Item item = (Item)element.FindPropertyRelative("item").objectReferenceValue;

                if (!MatchesSearch(item, searchString))
                {
                    continue;
                }
                GUILayout.BeginHorizontal();
                Color color = GUI.backgroundColor;
                Rect  rect  = GUILayoutUtility.GetRect(new GUIContent((item != null ? item.Name : "Null")), selectButton, GUILayout.Height(25f));
                rect.width         -= 25f;
                GUI.backgroundColor = (rect.Contains(Event.current.mousePosition) ? new Color(0, 1.0f, 0, 0.3f) : new Color(0, 0, 0, 0.0f));

                if (GUI.Button(rect, (item != null?item.Name:"Null"), selectButton))
                {
                    GUI.FocusControl("");
                    selectedIndex = i;
                    selectedÍtem  = item;
                }
                GUI.backgroundColor = color;
                Rect position = new Rect(rect.x + rect.width + 4f, rect.y + 4f, 25, 25);
                if (GUI.Button(position, "", "OL Minus"))
                {
                    serializedObject.Update();
                    elements.DeleteArrayElementAtIndex(i);
                    serializedObject.ApplyModifiedProperties();
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Add Item", GUILayout.Height(25)))
            {
                GUI.FocusControl("");
                serializedObject.Update();
                elements.InsertArrayElementAtIndex(elements.arraySize);
                elements.GetArrayElementAtIndex(elements.arraySize - 1).FindPropertyRelative("item").objectReferenceValue = null;
                elements.GetArrayElementAtIndex(elements.arraySize - 1).FindPropertyRelative("attachments").arraySize     = 0;
                serializedObject.ApplyModifiedProperties();
            }

            GUILayout.EndVertical();
        }
示例#7
0
    /// <summary>
    /// 获取默认导出路径
    /// </summary>
    public static string MakeDefaultOutputRootPath()
    {
        string projectPath = EditorTools.GetProjectPath();

        return($"{projectPath}/BuildBundles");
    }
示例#8
0
    private void createImportExportBox()
    {
        // Import/Export options
        GUILayout.BeginVertical(GUI.skin.box);

        EditorTools.createTitleBox("Load / save Options", true);

        GUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);
        EditorGUILayout.LabelField("Mode");

        syncOption = (SYNC_OPTIONS)EditorGUILayout.EnumPopup(syncOption, GUILayout.ExpandWidth(true));
        locTextGroup.currentSyncOption = (int)syncOption;

        GUILayout.EndHorizontal();


        if (syncOption == SYNC_OPTIONS.REMOTE_CSV_FILE)
        {
            GUIContent guiCont;
            string     langCode;
            for (int i = 0; i < locTextGroup.localGameLanguagesList.Length; i++)
            {
                langCode = locTextGroup.localGameLanguagesList[i].gameLanguage.code;
                GUILayout.BeginHorizontal(GUI.skin.box);
                if (toggles[i])
                {
                    guiCont = new GUIContent(" " + langCode + "_sheet_URL",
                                             EditorGUIUtility.IconContent("RotateTool").image,
                                             "Importing enabled for " + langCode + " language.");
                }
                else
                {
                    guiCont = new GUIContent(" " + langCode + "_sheet_URL",
                                             EditorGUIUtility.IconContent("RotateTool On").image,
                                             "Importing disabled for " + langCode + " language.");
                }

                locTextGroup.remoteCsvUrls[i] =
                    EditorGUILayout.TextField(guiCont, locTextGroup.remoteCsvUrls[i]);
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(5);

            EditorGUI.BeginDisabledGroup(drawToggles() && filesPending == 0);

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(new GUIContent(" Import", EditorTools.getIcon("CollabPull"))))
            {
                for (int i = 0; i < locTextGroup.remoteCsvUrls.Length; i++)
                {
                    if (!toggles[i])
                    {
                        continue;
                    }

                    importFromRemoteCsvSheet(i);
                }
            }

            GUILayout.EndHorizontal();

            EditorGUI.EndDisabledGroup();
        }
        else if (syncOption == SYNC_OPTIONS.LOCAL_CSV_FILE)
        {
            string[] fileNames       = new string[locTextGroup.localGameLanguagesList.Length];
            int      count           = 0;
            string   messageFileName = "";

            for (int i = 0; i < locTextGroup.localGameLanguagesList.Length; i++)
            {
                if (!toggles[i])
                {
                    continue;
                }
                count++;
                fileNames[i]     = locTextGroup.name + " - " + locTextGroup.localGameLanguagesList[i].gameLanguage.code + ".csv";
                messageFileName += fileNames[i];

                if (i != locTextGroup.localGameLanguagesList.Length - 1)
                {
                    messageFileName += "\n";
                }
            }

            EditorGUILayout.HelpBox(count +
                                    " files will be loaded/saved from/to folder:\n" +
                                    AKAGF_PATHS.LOCALIZATION_GROUPS_FILES_PATH + locTextGroup.name + "/\n\n" +
                                    "With the names: \n" +
                                    messageFileName, MessageType.Info);

            GUILayout.Space(5);

            EditorGUI.BeginDisabledGroup(drawToggles() && filesPending == 0);

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(new GUIContent(" Load from file", EditorTools.getIcon("CollabPush"))))
            {
                loadFromCSV(fileNames, GROUPS_CSV_FILES_PATH + locTextGroup.name + "/");
            }

            if (GUILayout.Button(new GUIContent(" Save to file", EditorTools.getIcon("CollabPull"))))
            {
                saveToCSV(fileNames, GROUPS_CSV_FILES_PATH + locTextGroup.name + "/");
            }

            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
        }

        GUILayout.Space(5);
        GUILayout.EndVertical();
    }
示例#9
0
    private void createLocalizedTextsBoxes()
    {
        GUILayout.BeginVertical(GUI.skin.box);

        EditorTools.createTitleBox("Localized Texts", true);


        if (locTextGroup.localizedTextsList.Count > 0)
        {
            EditorGUILayout.LabelField("Total: " + locTextGroup.localizedTextsList.Count, EditorStyles.boldLabel);
        }
        else
        {
            GUILayout.Label("This Localized Texts Group is Empty.");
        }

        GUILayout.BeginHorizontal();
        LocalizedTextsGroupName = EditorGUILayout.TextField("New Localized Text Name", LocalizedTextsGroupName);

        GUILayout.EndHorizontal();

        GUILayout.Space(5);

        GUILayout.BeginHorizontal();
        if (EditorTools.createListButton(" Add Text ", false, GUILayout.ExpandWidth(true)))
        {
            AddLocalizedText(LocalizedTextsGroupName);
        }

        if (EditorTools.createListButton(" Remove All ", true, GUILayout.ExpandWidth(true)) && EditorUtility.DisplayDialog("Remove All Localized Texts in " + locTextGroup.name + "?",
                                                                                                                           "Are you sure you want to remove all Localized texts from this group? "
                                                                                                                           , "Yes, totally sure.", "Cancel"))
        {
            for (int i = 0; i < localizedTextEditors.Length; i++)
            {
                localizedTextEditors[i].removeLocalizedText(false);
            }

            AssetDatabase.SaveAssets();
        }

        GUILayout.EndHorizontal();

        GUILayout.Space(5);

        // If there are different number of editors to Items, create them afresh.
        if (localizedTextEditors.Length != locTextGroup.localizedTextsList.Count)
        {
            // Destroy all the old editors.
            for (int i = 0; i < localizedTextEditors.Length; i++)
            {
                DestroyImmediate(localizedTextEditors[i]);
            }

            // Create new editors.
            CreateEditors();
        }


        // Display all the items.
        for (int i = 0; i < localizedTextEditors.Length; i++)
        {
            localizedTextEditors[i].OnInspectorGUI();

            if (i != localizedTextEditors.Length - 1)
            {
                EditorTools.createHorizontalSeparator();
            }
        }

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

        GUILayout.EndVertical();
    }
示例#10
0
    public override void OnInspectorGUI()
    {
        // Update the state of the serializedObject to the current values of the target.
        serializedObject.Update();

        Undo.RecordObject(targetElement, "save data");


        EditorTools.createPopUpMenuWithObjectsNames(ref targetElement.saveData, ref saveDataSelectedIndex, "Data Save");

        //if (targetElement.saveData)
        //    saveDataSelectedIndex = savesDatasAux.IndexOf(targetElement.saveData);

        //string[] names = ScriptableObjectUtility.getAllInstancesNames<SaveData>();

        //saveDataSelectedIndex = EditorGUILayout.Popup("Save Data", saveDataSelectedIndex, names);

        //if (savesDatasAux.Count == 0) {
        //    EditorGUILayout.HelpBox("No ScriptableObject Save Data Reference Found!", MessageType.Warning);
        //}
        //else
        //    targetElement.saveData = savesDatasAux[saveDataSelectedIndex];


        GUILayout.Space(5);

        // Button for adding another element just by resizing the arrays
        if (GUILayout.Button("Add Saver"))
        {
            Array.Resize(ref targetElement.saversData, targetElement.saversData.Length + 1);
            Array.Resize(ref isExpanded, targetElement.saversData.Length);

            // EditorUtility.SetDirty(targetElement);
            serializedObject.ApplyModifiedProperties();
            serializedObject.Update();
        }

        GUILayout.Space(5);

        // Iterate throught all the saverData elements
        for (int i = 0; i < targetElement.saversData.Length; i++)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);

            GUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);
            //EditorGUILayout.LabelField(targetItem.name);

            // Handle foldout through isExpanded variable
            isExpanded[i] = EditorGUILayout.Foldout(isExpanded[i], new GUIContent(targetElement.saversData[i].uniquePrefixID), true, EditorStyles.foldout);

            // Create a remove button in each element of the list
            if (GUILayout.Button(" - ", GUILayout.ExpandWidth(false)))
            {
                var list = new List <StateSaverElement>(targetElement.saversData);
                list.RemoveAt(i);
                targetElement.saversData = list.ToArray();

                //Array.Resize(ref targetElement.saversData, targetElement.saversData.Length - 1);
                Array.Resize(ref isExpanded, targetElement.saversData.Length);
                //serializedObject.ApplyModifiedProperties();
                //serializedObject.Update();
                continue;
            }

            GUILayout.EndHorizontal();

            // Designer is inspecting the content of this element
            if (isExpanded[i])
            {
                GUILayout.Space(5);

                /* Element Properties */
                targetElement.saversData[i].uniquePrefixID       = EditorGUILayout.TextField("Unique Prefix ID", targetElement.saversData[i].uniquePrefixID);
                targetElement.saversData[i].persistentGameObject = EditorGUILayout.ObjectField("Persistent GameObject", targetElement.saversData[i].persistentGameObject, typeof(GameObject), true) as GameObject;
                if (!targetElement.saversData[i].persistentGameObject)
                {
                    EditorGUILayout.HelpBox("No Persistent Game Object Reference Found!", MessageType.Warning);
                }


                targetElement.saversData[i].saveGameObjectState = EditorGUILayout.Toggle("Save GameObject State", targetElement.saversData[i].saveGameObjectState, GUILayout.ExpandWidth(false));
                targetElement.saversData[i].savePositionState   = EditorGUILayout.Toggle("Save Position State", targetElement.saversData[i].savePositionState, GUILayout.ExpandWidth(false));
                targetElement.saversData[i].saveRotationState   = EditorGUILayout.Toggle("Save Rotation State", targetElement.saversData[i].saveRotationState, GUILayout.ExpandWidth(false));

                targetElement.saversData[i].saveBehaviourEnableState = EditorGUILayout.Toggle("Save Behaviour Enable State", targetElement.saversData[i].saveBehaviourEnableState, GUILayout.ExpandWidth(false));

                // Creates the saversData only in case that having a valid reference to a GameObject
                if (targetElement.saversData[i].persistentGameObject)
                {
                    initSavers(ref targetElement.saversData[i]);

                    if (targetElement.saversData[i].saveBehaviourEnableState)
                    {
                        // Get all the behaviours component attached to persisten GameObject
                        Behaviour[] behaviours = targetElement.saversData[i].persistentGameObject.GetComponents <Behaviour>();

                        // Create an array of strings to store the names of the found behaviours
                        string[] behavioursNames = new string[behaviours.Length];

                        for (int j = 0; j < behaviours.Length; j++)
                        {
                            behavioursNames[j] = behaviours[j].GetType().ToString();
                        }

                        // Fetch all behaviours that must to be saved from a maskField of persistent GameObject contained behaviours
                        targetElement.saversData[i].behaviorStatesflags = EditorGUILayout.MaskField("Behaviours to Save", targetElement.saversData[i].behaviorStatesflags, behavioursNames);

                        List <Behaviour> selectedOptions = new List <Behaviour>();

                        for (int j = 0; j < behaviours.Length; j++)
                        {
                            if ((targetElement.saversData[i].behaviorStatesflags & (1 << j)) == (1 << j))
                            {
                                selectedOptions.Add(behaviours[j]);
                            }
                        }

                        // Store the behaviours in target behaviours list
                        targetElement.saversData[i].persistentGameObjectSelectedBehaviours = selectedOptions;
                    }
                    else
                    {
                        // If save behaviours checkbox is unmarked, set the array to null
                        targetElement.saversData[i].persistentGameObjectSelectedBehaviours.Clear();
                        targetElement.saversData[i].behaviorStatesflags = 0;
                    }
                }
            }

            EditorGUILayout.EndVertical();



            // Push data back from the serializedObject to the target.
            serializedObject.ApplyModifiedProperties();
        }

        GUILayout.Space(5);
    }
示例#11
0
    public override void OnInspectorGUI()
    {
        AssetUIAtlas uiAtla = target as AssetUIAtlas;


        GUILayout.Space(6);
        EditorGUIUtility.labelWidth = 110;


        GUILayout.Label(string.Format("图集: "));

        Texture2D atla_texture = EditorGUILayout.ObjectField(uiAtla.texture, typeof(Texture2D), true) as Texture2D;

        string path_texture = AssetDatabase.GetAssetPath(atla_texture);

        if (atla_texture != null)
        {
            GUILayout.Label(string.Format("{0} x {1}\n{2}\n{3}",
                                          atla_texture.width,
                                          atla_texture.height,
                                          atla_texture.format,
                                          atla_texture.filterMode));
        }

        if (EditorTools.DrawHeader("显示图集", true, false))
        {
            Rect rect = GUILayoutUtility.GetRect(320, 320, GUI.skin.box);

            GUI.Box(rect, uiAtla.texture);
        }

        if (uiAtla.sprites != null)
        {
            GUILayout.Label(string.Format("元件数[{0}]", uiAtla.sprites.Count));
        }

        DrawTargetArray(uiAtla.sprites, true);

        if (GUILayout.Button("刷新元件"))
        {
            FillSpriteArray(uiAtla.sprites, path_texture);
        }

        if (uiAtla.texture != atla_texture)
        {
            if (uiAtla.texture != null)
            {
                AssetImporter ai = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(uiAtla.texture));
                ai.assetBundleName = string.Empty;
            }

            if (atla_texture != null)
            {
                string assetbundleName = AssetDatabase.GetAssetPath(target)
                                         .Replace(".prefab", "")
                                         .Replace(".asset", "")
                                         .Replace("Assets/AssetBases/PrefabAssets/", "");
                AssetImporter ai = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(atla_texture));
                ai.assetBundleName = assetbundleName;
            }

            uiAtla.texture = atla_texture;

            FillSpriteArray(uiAtla.sprites, path_texture);



            EditorTools.SetDirty(uiAtla);
        }
    }
示例#12
0
    private static void DrawUpdateGroup(UIUpdateGroup uigroup, int tagidx, Color color)
    {
        if (uigroup == null)
        {
            return;
        }

        GUI.backgroundColor = color;

        GUILayout.BeginHorizontal();
        GUILayout.Space(tagidx * 50);

//		EditorGUILayout.ObjectField (uigroup, uigroup.GetType (),false);

        GUI.contentColor = Color.white;
        EditorTools.DrawPingBox(uigroup, string.Format("{0}  <{1}>", uigroup.updateKey, uigroup.GetType().Name));

        GUILayout.EndHorizontal();

        ++tagidx;

        for (int k = 0; k < uigroup.ListUpdateUI.Count; k++)
        {
            if (uigroup.ListUpdateUI [k] is UIUpdateGroup)
            {
                DrawUpdateGroup(uigroup.ListUpdateUI [k] as UIUpdateGroup, tagidx, color);
            }
            else
            {
                GUI.backgroundColor = color;
                GUILayout.BeginHorizontal();
                GUILayout.Space(tagidx * 50);
                IUIUpdate ui = uigroup.ListUpdateUI[k] as IUIUpdate;
                if (ui != null)
                {
                    EditorTools.DrawPingBox(uigroup.ListUpdateUI[k], string.Format("{0}  <{1}>", ui.updateKey, ui.GetType().Name));
                }
                else
                {
                    GUI.backgroundColor = Color.grey;
                    EditorTools.DrawPingBox(null, "<null>");
                }
                GUILayout.EndHorizontal();
            }
        }

        if (uigroup.MapDynamicUI != null)
        {
            ++tagidx;
            foreach (Object obj in uigroup.MapDynamicUI.Values)
            {
                if (obj is UIUpdateGroup)
                {
                    DrawUpdateGroup(obj as UIUpdateGroup, tagidx, Color.red);
                }
                else
                {
                    GUI.backgroundColor = color;
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(tagidx * 50);
                    IUIUpdate ui = obj as IUIUpdate;

                    if (ui != null)
                    {
                        EditorTools.DrawPingBox(obj, string.Format("{0}  <{1}>", ui.updateKey, ui.GetType().Name));
                    }
                    else
                    {
                        GUI.backgroundColor = Color.grey;
                        EditorTools.DrawPingBox(null, "<null>");
                    }

                    GUILayout.EndHorizontal();
                }
            }
        }
    }
示例#13
0
 public static void IncrementEndingVersion()
 {
     EditorTools.IncrementEndingVersion(m_AssetPath, m_SaveAssetFullPath);
 }
示例#14
0
        ////////////////////////////////////////
        ///////////GUI AND EDITOR STUFF/////////
        ////////////////////////////////////////
#if UNITY_EDITOR
        protected override void OnClipGUI(Rect rect)
        {
            EditorTools.DrawLoopedAudioTexture(rect, audioClip, length, clipOffset);
        }
示例#15
0
 public static void ActivateTool()
 {
     EditorTools.SetActiveTool <ChiselUVMoveTool>();
 }
示例#16
0
        public override void OnInspectorGUI()
        {
            if (folderLoaded)
            {
                EditorTools.Message_static("Loading Complete", "Loaded " + modelCount.ToString() + " models from 'Assets/" + folderString + ".");
                folderLoaded    = false;
                folderString    = "";
                filePathsToLoad = null;
            }

            DrawDefaultInspector();

            if (tools.Button("Load Folder"))
            {
                if (tools.Message("Load Baked Animation In Folder", "Select one of the models in the folder you wish to load.", "OK", "Cancel"))
                {
                    EditorGUIUtility.ShowObjectPicker <GameObject>(null, false, "", objectPickerID);
                }
                GUIUtility.ExitGUI();
            }

            Event currentEvent = Event.current;

            if (currentEvent.type == EventType.ExecuteCommand || currentEvent.type == EventType.ValidateCommand)
            {
                if (currentEvent.commandName == "ObjectSelectorClosed")
                {
                    if (EditorGUIUtility.GetObjectPickerControlID() == objectPickerID)
                    {
                        Object pickedObject = EditorGUIUtility.GetObjectPickerObject();

                        if (pickedObject != null)
                        {
                            folderString = AssetDatabase.GetAssetPath(pickedObject);
                            folderString = folderString.Replace(Path.GetFileName(folderString), "");
                            folderString = folderString.Replace("Assets/", "");

                            filePathsToLoad = Directory.GetFiles(Application.dataPath + "/" + folderString);

                            bool replaceExisting = tools.Message("Load Folder", "Replace any existing models?", "Yes", "No");

                            tools.StartEdit(animator, "Mesh Animator Loaded models");

                            if (replaceExisting)
                            {
                                animator.models.Clear();
                            }

                            modelCount = animator.LoadFromFolder(filePathsToLoad, folderString);

                            tools.EndEdit(animator);

                            folderLoaded = true;

                            GUIUtility.ExitGUI();
                        }
                    }
                }
            }

            if (animator.paused)
            {
                if (tools.Button("Play"))
                {
                    animator.Play();
                }
            }
            else
            {
                if (tools.Button("Pause"))
                {
                    animator.Pause();
                }
            }
        }
 static void SetAssetBundlesNameByFileName(List <string> pathFiles, string name)
 {
     for (int i = 0, max = pathFiles.Count; i < max; i++)
     {
         string strBundleName = EditorTools.GetParentFileName(pathFiles[i], 2) + "/" + EditorTools.GetFileName(pathFiles[i]);
         string newfile       = pathFiles[i].Replace(Application.dataPath, "Assets");
         //在代码中给资源设置AssetBundleName
         AssetImporter assetImporter = AssetImporter.GetAtPath(newfile);
         assetImporter.assetBundleName = name + "/" + strBundleName + ".ab";
         //assetImporter.assetBundleVariant = "ab";
         EditorUtility.DisplayProgressBar(strBundleName, "", (float)i / (float)max);
     }
 }
示例#18
0
        public void DrawBlockPanel(BlockPanelData panel, int level, int fromQuadrant = -1)
        {
            for (int j = panel.buttons.Count; j < order.Length; j++)
            {
                panel.buttons.Add(null);
            }

            string panelTitle = level == 1 ? "Root Panel" : "Level " + level + " Panel";

            if (EditorTools.DrawHeader(panelTitle))
            {
                EditorTools.BeginContents();

                for (int i = 0; i < order.Length; i++)
                {
                    int    quadrant = order[i];
                    string name     = names[i];

                    if (EditorTools.DrawHeader(panelTitle + " -- " + names[quadrant] + " Button"))
                    {
                        EditorTools.BeginContents();

                        if (IsOppositeQuadrant(quadrant, fromQuadrant))
                        {
                            EditorGUILayout.LabelField("Can not use");
                        }
                        else
                        {
                            BlockButtonData button = panel.buttons[quadrant];

                            if (button == null)
                            {
                                if (GUILayout.Button("Create Button"))
                                {
                                    button = new BlockButtonData();
                                    panel.buttons[quadrant] = button;
                                    dirty = true;
                                }
                            }
                            else
                            {
                                DrawBlockButton(button, quadrant, level);
                                if (GUILayout.Button("Delete Button"))
                                {
                                    panel.buttons[quadrant] = null;
                                    dirty = true;
                                }
                            }
                        }
                        EditorTools.EndContents();
                    }
                }

                if (GUI.changed)
                {
                    dirty = true;
                }

                EditorTools.EndContents();
            }
        }
示例#19
0
        /// <summary>
        /// Draws the target object.
        /// </summary>
        /// <param name="_control">Control.</param>
        /// <param name="_target">Target.</param>
        /// <param name="_title">Title.</param>
        /// <param name="_help">Help.</param>
        public static void DrawTargetObject(ICECreatureControl _control, TargetObject _target, string _title, string _help = "")
        {
            if (_control == null || _target == null)
            {
                return;
            }

            _target.SetIsPrefab(EditorTools.IsPrefab(_target.TargetGameObject));

            // PREPARATION END

            if (!Application.isPlaying && !EditorTools.IsPrefab(_control.gameObject))
            {
                // TARGET OBJECT LINE BEGIN
                ICEEditorLayout.BeginHorizontal();

                if (_target.TargetGameObject == null)
                {
                    GUI.backgroundColor = Color.red;
                }
                else if (_target.Active)
                {
                    GUI.backgroundColor = Color.green;
                }

                string _target_title = "Target Object " + (_target.IsValid?(_target.IsPrefab?"(prefab)":"(scene)"):"(null)");

                if (_target.AccessType == TargetAccessType.NAME)
                {
                    _target.SetTargetByName(Popups.TargetPopup(_target_title, "", _target.TargetName, ""));
                }
                else if (_target.AccessType == TargetAccessType.TAG)
                {
                    _target.SetTargetByTag(EditorGUILayout.TagField(new GUIContent(_target_title, ""), _target.TargetTag));
                }
                else if (_target.AccessType == TargetAccessType.TYPE)
                {
                    _target.SetTargetByType((EntityClassType)EditorGUILayout.EnumPopup(new GUIContent(_target_title, ""), _target.TargetEntityType));
                }
                else
                {
                    _target.SetTargetByGameObject((GameObject)EditorGUILayout.ObjectField(_target_title, _target.TargetGameObject, typeof(GameObject), true));
                }


                GUI.backgroundColor = ICEEditorLayout.DefaultBackgroundColor;

                // Type Enum Popup
                int _indent = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;
                _target.AccessType    = (TargetAccessType)EditorGUILayout.EnumPopup(_target.AccessType, ICEEditorStyle.Popup, GUILayout.Width(50));
                EditorGUI.indentLevel = _indent;


                if (_target.TargetGameObject != null)
                {
                    ICEEditorLayout.ButtonDisplayObject(_target.TargetGameObject.transform.position);
                    ICEEditorLayout.ButtonSelectObject(_target.TargetGameObject, ICEEditorStyle.CMDButtonDouble);

                    //_target.UseChildObjects = ICEEditorLayout.CheckButtonSmall( "CHD", "Allows the selection of own child objects", _target.UseChildObjects, ICEEditorLayout.SelectionOptionGroup3Color, ICEEditorLayout.SelectionOptionGroup3SelectedColor );

                    //if( _target.TargetGameObject.GetComponent<ICECreatureTargetAttribute>() != null )
                    {
                        EditorGUI.BeginDisabledGroup(_target.ReadTargetAttributeData() == null);
                        GUI.backgroundColor = Color.green;
                        if (ICEEditorLayout.ButtonSmall("TAV", "Use target attribute values"))
                        {
                            _target.SetTargetDefaultValues(_target.ReadTargetAttributeData());
                        }
                        GUI.backgroundColor = ICEEditorLayout.DefaultBackgroundColor;
                        EditorGUI.EndDisabledGroup();
                    }
                }
                else
                {
                    if (ICEEditorLayout.AutoButton("Creates an empty GameObject as target with default settings"))
                    {
                        WizardEditor.WizardRandomTarget(_control, _target);
                    }
                }

                ICEEditorLayout.EndHorizontal(Info.TARGET_OBJECT);
                // TARGET OBJECT LINE END
            }
            else
            {
                DrawTargetObjectBlind(_target);
            }
        }
 public static void TestOpenAssetsFloder()
 {
     Dialog.Info(EditorTools.OpenAssetsFolder("Open"));
 }
示例#21
0
    /// <summary>
    /// 清空流文件夹
    /// </summary>
    public static void ClearStreamingAssetsFolder()
    {
        string streamingPath = Application.dataPath + "/StreamingAssets";

        EditorTools.ClearFolder(streamingPath);
    }
 public static void TestSaveAssetsFloder()
 {
     Dialog.Info(EditorTools.SaveAssetsFolder("Save"));
 }
    private void editorGUI(bool removeButton)
    {
        EditorGUILayout.BeginVertical(GUI.skin.box);

        GUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);

        scriptableScene.isExpanded = EditorGUILayout.Foldout(scriptableScene.isExpanded, new GUIContent(scriptableScene.name), true, EditorStyles.foldout);

        SceneAsset oldScene = AssetDatabase.LoadAssetAtPath <SceneAsset>(scriptableScene.scenePath);

        serializedObject.Update();

        // Display a button showing a '-' that if clicked removes this Condition from the AllConditions asset.
        if (removeButton && EditorTools.createListButton("-", true, GUILayout.Width(removeButtonWidth)))
        {
            AllGameScriptableScenesEditor.RemoveScriptableScene(scriptableScene);
            return;
        }

        GUILayout.EndHorizontal();

        if (scriptableScene.isExpanded)
        {
            EditorGUI.BeginChangeCheck();

            EditorGUI.indentLevel += 1;
            EditorGUILayout.LabelField("Unity Scene");
            EditorGUI.indentLevel -= 1;
            GUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins);

            SceneAsset newScene = EditorGUILayout.ObjectField(oldScene, typeof(SceneAsset), false) as SceneAsset;

            GUILayout.Space(5);

            EditorTools.createArrayPropertyButtons(sceneStartingPositionsNamesProperty, sceneStartingPositionsNamesPropName, GUILayout.Width(30f), true);

            if (sceneStartingPositionsNamesProperty.arraySize > 0)
            {
                for (int i = 0; i < sceneStartingPositionsNamesProperty.arraySize; i++)
                {
                    GUILayout.Space(5);
                    EditorGUILayout.BeginVertical(GUI.skin.box);
                    EditorGUILayout.PropertyField(sceneStartingPositionsNamesProperty.GetArrayElementAtIndex(i), new GUIContent("Position Name " + i), true);
                    EditorGUILayout.EndVertical();
                }
            }

            GUILayout.EndVertical();

            if (newScene)
            {
                scriptableScene.name = newScene.name;
            }


            if (EditorGUI.EndChangeCheck() && newScene != null)
            {
                string newPath = AssetDatabase.GetAssetPath(newScene.GetInstanceID());
                scenePathProperty.stringValue = newPath;
                AssetDatabase.SaveAssets();
            }
        }

        EditorGUILayout.EndVertical();

        // Push the values from the serializedObject back to the target.
        serializedObject.ApplyModifiedProperties();
    }
 public static void TestOpenAssetsFile()
 {
     Dialog.Info(EditorTools.OpenAssetsFile("Open"));
 }
    protected void Draw_MarkPoint()
    {
        AvatarController avatar = target as AvatarController;

        if (EditorTools.DrawHeader("角色挂点", false, false))
        {
            EditorTools.BeginContents(false);
            if (GUILayout.Button("自动添加"))
            {
                if (AddToMarkPoint(avatar))
                {
                    EditorTools.SetDirty(avatar);
                    return;
                }
            }
            GameObject Obj_markPoint_buffer = null;
            Obj_markPoint_buffer = (GameObject)EditorGUILayout.ObjectField("添加挂点", Obj_markPoint_buffer, typeof(GameObject), true);
            bool isExist = false;
            for (int k = 0; k < avatar.markPoint.listMarkPoint.Count; k++)
            {
                if (avatar.markPoint.listMarkPoint[k] == null)
                {
                    avatar.markPoint.listMarkPoint.RemoveAt(k);
                    k--;
                    continue;
                }
                if (Obj_markPoint_buffer != null && avatar.markPoint.listMarkPoint[k] == Obj_markPoint_buffer)
                {
                    isExist = true;
                }
                GUILayout.BeginHorizontal();
                GUILayout.Space(6);
                GUI.backgroundColor = new Color(0.8f, 0.5f, 0);

                if (GUILayout.Button(avatar.markPoint.listMarkPoint [k].name, GUILayout.Width(150)))
                {
                    EditorTools.PingObject(avatar.markPoint.listMarkPoint [k]);
                }
                GUI.backgroundColor = Color.red;
                if (GUILayout.Button("X", GUILayout.Width(20)))
                {
                    //删除挂点
                    if (GUI.changed)
                    {
                        EditorTools.RegisterUndo("AvatarController Change", avatar);
                        GameObject markPoint = avatar.markPoint.listMarkPoint[k];
                        avatar.markPoint.listMarkPoint.Remove(markPoint);
                        EditorTools.SetDirty(avatar);
                        k--;
                    }
                }
                GUI.backgroundColor = Color.white;
                GUILayout.EndHorizontal();
            }

            if (!isExist)
            {
                if (Obj_markPoint_buffer != null)
                {
                    if (GUI.changed)
                    {
                        EditorTools.RegisterUndo("AvatarController Change", avatar);
                        avatar.markPoint.listMarkPoint.Add((GameObject)Obj_markPoint_buffer);
                        EditorTools.SetDirty(avatar);
                    }
                }
            }



            GUI.backgroundColor = Color.white;
            EditorTools.EndContents();
        }
    }
 public static void TestSaveAssetsFile()
 {
     Dialog.Info(EditorTools.SaveAssetsFile("Save", Application.dataPath, "Plugin", ".meat"));
 }
 protected override void DoSearchGUI()
 {
     string[] searchResult = EditorTools.SearchField(m_SearchString, searchFilter, searchFilters);
     searchFilter   = searchResult [0];
     m_SearchString = string.IsNullOrEmpty(searchResult [1])?searchFilter:searchResult[1];
 }
 public static void TestCompanyName()
 {
     Dialog.Info(EditorTools.GetCompanyName());
 }
示例#29
0
        private static List <IssueRecord> CheckObjectsForIssues(string path, List <GameObject> gameObjects, bool checkingScene = true)
        {
            List <IssueRecord> issues = new List <IssueRecord>();

            string currentSceneName = null;
            int    gameObjectsCount = gameObjects.Count;

            for (int i = 0; i < gameObjectsCount; i++)
            {
                if (checkingScene)
                {
                    if (String.IsNullOrEmpty(currentSceneName))
                    {
                        currentSceneName = Path.GetFileNameWithoutExtension(path);
                    }

                    if (EditorUtility.DisplayCancelableProgressBar(String.Format(PROGRESS_CAPTION, currentTotalIndex, totalCount), String.Format("Processing scene: {0} ... {1}%", currentSceneName, i * 100 / gameObjectsCount), (float)currentTotalIndex / scenesCount))
                    {
                        return(null);
                    }
                }
                else
                {
                    if (EditorUtility.DisplayCancelableProgressBar(String.Format(PROGRESS_CAPTION, currentTotalIndex, totalCount), "Processing prefabs files...", (float)(currentTotalIndex - scenesCount) / prefabsCount))
                    {
                        return(null);
                    }
                }

                GameObject go = gameObjects[i];

                if (!MaintainerSettings.Issues.touchInactiveGameObjects)
                {
                    if (checkingScene)
                    {
                        if (!go.activeInHierarchy)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (!go.activeSelf)
                        {
                            continue;
                        }
                    }
                }

                if (MaintainerSettings.Issues.UndefinedTags)
                {
                    bool undefinedTag = false;
                    try
                    {
                        if (String.IsNullOrEmpty(go.tag))
                        {
                            undefinedTag = true;
                        }
                    }
                    catch (UnityException e)
                    {
                        if (e.Message.Contains("undefined tag"))
                        {
                            undefinedTag = true;
                        }
                        else
                        {
                            Debug.LogError(Maintainer.LOG_PREFIX + " Unknown error: " + e);
                        }
                    }

                    if (undefinedTag)
                    {
                        issues.Add(new IssueRecord(go, i, path, IssueType.UndefinedTag));
                    }
                }

                if (MaintainerSettings.Issues.UnnamedLayers)
                {
                    int layerIndex = go.layer;
                    if (String.IsNullOrEmpty(LayerMask.LayerToName(layerIndex)))
                    {
                        issues.Add(new IssueRecord(go, null, null, " (index: " + layerIndex + ")", i, path, IssueType.UnnamedLayer));
                    }
                }

                Component[] components      = go.GetComponents <Component>();
                int         componentsCount = components.Length;

                if (checkingScene)
                {
                    PrefabType prefabType = PrefabUtility.GetPrefabType(go);

                    if (prefabType != PrefabType.None)
                    {
                        // checking if we're inside of nested prefab with same type as root
                        // allows to skip detections of missed and disconnected prefabs children
                        GameObject rootPrefab            = PrefabUtility.FindRootGameObjectWithSameParentPrefab(go);
                        bool       rootPrefabHasSameType = false;
                        if (rootPrefab != go)
                        {
                            PrefabType rootPrefabType = PrefabUtility.GetPrefabType(rootPrefab);
                            if (rootPrefabType == prefabType)
                            {
                                rootPrefabHasSameType = true;
                            }
                        }

                        if (prefabType == PrefabType.MissingPrefabInstance)
                        {
                            if (MaintainerSettings.Issues.MissingPrefabs && !rootPrefabHasSameType)
                            {
                                issues.Add(new IssueRecord(go, i, path, IssueType.MissingPrefab));
                            }
                        }
                        else if (prefabType == PrefabType.DisconnectedPrefabInstance ||
                                 prefabType == PrefabType.DisconnectedModelPrefabInstance)
                        {
                            if (MaintainerSettings.Issues.DisconnectedPrefabs && !rootPrefabHasSameType)
                            {
                                issues.Add(new IssueRecord(go, i, path, IssueType.DisconnectedPrefab));
                            }
                        }

                        // checking if this game object is actually prefab instance
                        // without any changes, so we can skip it if we have
                        // assets search enabled
                        if (prefabType != PrefabType.DisconnectedPrefabInstance &&
                            prefabType != PrefabType.DisconnectedModelPrefabInstance &&
                            prefabType != PrefabType.MissingPrefabInstance && MaintainerSettings.Issues.lookInAssets)
                        {
                            bool skipThisPrefabInstance = true;

                            // we shouldn't skip this object if it's nested
                            if (EditorTools.GetDepthInHierarchy(go.transform, rootPrefab.transform) >= 2)
                            {
                                skipThisPrefabInstance = false;
                            }
                            else
                            {
                                for (int j = 0; j < componentsCount; j++)
                                {
                                    Component component = components[j];

                                    if (component == null || component is Transform ||
                                        (component is Behaviour && !MaintainerSettings.Issues.touchDisabledComponents && !(component as Behaviour).enabled))
                                    {
                                        continue;
                                    }

                                    SerializedObject   so = new SerializedObject(component);
                                    SerializedProperty sp = so.GetIterator();

                                    while (sp.NextVisible(true))
                                    {
                                        if (sp.prefabOverride)
                                        {
                                            skipThisPrefabInstance = false;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (skipThisPrefabInstance)
                            {
                                continue;
                            }
                        }
                    }
                }
                else
                {
                    // increasing prefab item index for progress bar
                    currentTotalIndex++;
                }

                Dictionary <Type, int> uniqueTypes = null;
                List <int>             similarComponentsIndexes = null;

                for (int j = 0; j < componentsCount; j++)
                {
                    Component component = components[j];

                    if (component == null)
                    {
                        if (MaintainerSettings.Issues.MissingComponents)
                        {
                            issues.Add(new IssueRecord(go, i, path, IssueType.MissingComponent));
                        }
                        continue;
                    }

                    if (!MaintainerSettings.Issues.touchDisabledComponents)
                    {
                        if (EditorUtility.GetObjectEnabled(component) == 0)
                        {
                            continue;
                        }
                    }

                    if (component is Transform)
                    {
                        continue;
                    }

                    if (MaintainerSettings.Issues.DuplicateComponents)
                    {
                        // initializing dictionary and list on first usage
                        if (uniqueTypes == null)
                        {
                            uniqueTypes = new Dictionary <Type, int>(componentsCount);
                        }
                        if (similarComponentsIndexes == null)
                        {
                            similarComponentsIndexes = new List <int>(componentsCount);
                        }

                        Type componentType = component.GetType();

                        // checking if current component type alredy met before
                        if (uniqueTypes.ContainsKey(componentType))
                        {
                            int uniqueTypeIndex = uniqueTypes[componentType];

                            // checking if initially met component index already in indexes list
                            // since we need to compare all duplicate candidates against initial component
                            if (!similarComponentsIndexes.Contains(uniqueTypeIndex))
                            {
                                similarComponentsIndexes.Add(uniqueTypeIndex);
                            }

                            // adding current component index to the indexes list
                            similarComponentsIndexes.Add(j);
                        }
                        else
                        {
                            uniqueTypes.Add(componentType, j);
                        }
                    }

                    if (component is MeshCollider)
                    {
                        if (MaintainerSettings.Issues.EmptyMeshColliders)
                        {
                            if ((component as MeshCollider).sharedMesh == null)
                            {
                                issues.Add(new IssueRecord(go, component, i, path, IssueType.EmptyMeshCollider));
                            }
                        }
                    }
                    else if (component is MeshFilter)
                    {
                        if (MaintainerSettings.Issues.EmptyMeshFilters)
                        {
                            if ((component as MeshFilter).sharedMesh == null)
                            {
                                issues.Add(new IssueRecord(go, component, i, path, IssueType.EmptyMeshFilter));
                            }
                        }
                    }
                    else if (component is Renderer)
                    {
                        if (MaintainerSettings.Issues.EmptyRenderers)
                        {
                            if ((component as Renderer).sharedMaterial == null)
                            {
                                issues.Add(new IssueRecord(go, component, i, path, IssueType.EmptyRenderer));
                            }
                        }
                    }
                    else if (component is Animation)
                    {
                        if (MaintainerSettings.Issues.EmptyAnimations)
                        {
                            if ((component as Animation).GetClipCount() <= 0 && (component as Animation).clip == null)
                            {
                                issues.Add(new IssueRecord(go, component, i, path, IssueType.EmptyAnimation));
                            }
                        }
                    }

                    SerializedObject   so = new SerializedObject(component);
                    SerializedProperty sp = so.GetIterator();

                    while (sp.NextVisible(true))
                    {
                        string propertyName     = null;
                        string fullPropertyPath = sp.propertyPath;
                        bool   isArrayItem      = fullPropertyPath.EndsWith("]", StringComparison.Ordinal);


                        if (MaintainerSettings.Issues.MissingReferences)
                        {
                            if (sp.propertyType == SerializedPropertyType.ObjectReference)
                            {
                                if (sp.objectReferenceValue == null && sp.objectReferenceInstanceIDValue != 0)
                                {
                                    if (isArrayItem)
                                    {
                                        propertyName = GetArrayItemNameAndIndex(sp, fullPropertyPath);
                                    }
                                    else
                                    {
                                        propertyName = sp.name;
                                    }
                                    issues.Add(new IssueRecord(go, component, propertyName, i, path, IssueType.MissingReference));
                                }
                            }
                        }

                        if (checkingScene || !MaintainerSettings.Issues.SkipEmptyArrayItemsOnPrefabs)
                        {
                            if (MaintainerSettings.Issues.EmptyArrayItems && isArrayItem)
                            {
                                if (sp.propertyType == SerializedPropertyType.ObjectReference &&
                                    sp.objectReferenceValue == null &&
                                    sp.objectReferenceInstanceIDValue == 0)
                                {
                                    if (String.IsNullOrEmpty(propertyName))
                                    {
                                        propertyName = GetArrayItemNameAndIndex(sp, fullPropertyPath);
                                    }
                                    issues.Add(new IssueRecord(go, component, propertyName, i, path, IssueType.EmptyArrayItem));
                                }
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                }

                if (MaintainerSettings.Issues.DuplicateComponents)
                {
                    if (similarComponentsIndexes != null && similarComponentsIndexes.Count > 0)
                    {
                        int         similarComponentsCount  = similarComponentsIndexes.Count;
                        List <long> similarComponentsHashes = new List <long>(similarComponentsCount);

                        for (int j = 0; j < similarComponentsCount; j++)
                        {
                            int       componentIndex = similarComponentsIndexes[j];
                            Component component      = components[componentIndex];

                            long componentHash = 0;

                            SerializedObject   so = new SerializedObject(component);
                            SerializedProperty sp = so.GetIterator();
                            while (sp.NextVisible(true))
                            {
                                componentHash += EditorTools.GetPropertyHash(sp);
                            }

                            similarComponentsHashes.Add(componentHash);
                        }

                        List <long> distinctItems = new List <long>(similarComponentsCount);

                        for (int j = 0; j < similarComponentsCount; j++)
                        {
                            int componentIndex = similarComponentsIndexes[j];

                            if (distinctItems.Contains(similarComponentsHashes[j]))
                            {
                                issues.Add(new IssueRecord(go, components[componentIndex], i, path, IssueType.DuplicateComponent));
                            }
                            else
                            {
                                distinctItems.Add(similarComponentsHashes[j]);
                            }
                        }
                    }
                }
            }
            return(issues);
        }
示例#30
0
    void DrawRotation(bool isWidget)
    {
        GUILayout.BeginHorizontal();
        {
            bool reset = GUILayout.Button("R", GUILayout.Width(20f));

            Vector3 visible = (serializedObject.targetObject as Transform).localEulerAngles;

            visible.x = MathTools.WrapAngle(visible.x);
            visible.y = MathTools.WrapAngle(visible.y);
            visible.z = MathTools.WrapAngle(visible.z);

            Axes changed = CheckDifference(mRot);
            Axes altered = Axes.None;

            GUILayoutOption opt = GUILayout.MinWidth(30f);

            if (FloatField("X", ref visible.x, (changed & Axes.X) != 0, isWidget, opt))
            {
                altered |= Axes.X;
            }
            if (FloatField("Y", ref visible.y, (changed & Axes.Y) != 0, isWidget, opt))
            {
                altered |= Axes.Y;
            }
            if (FloatField("Z", ref visible.z, (changed & Axes.Z) != 0, false, opt))
            {
                altered |= Axes.Z;
            }

            if (reset)
            {
                mRot.quaternionValue = Quaternion.identity;
            }
            else if (altered != Axes.None)
            {
                EditorTools.RegisterUndo("Change Rotation", serializedObject.targetObjects);

                foreach (Object obj in serializedObject.targetObjects)
                {
                    Transform t = obj as Transform;
                    Vector3   v = t.localEulerAngles;

                    if ((altered & Axes.X) != 0)
                    {
                        v.x = visible.x;
                    }
                    if ((altered & Axes.Y) != 0)
                    {
                        v.y = visible.y;
                    }
                    if ((altered & Axes.Z) != 0)
                    {
                        v.z = visible.z;
                    }

                    t.localEulerAngles = v;
                }
            }
        }
        GUILayout.EndHorizontal();
    }