Exemplo n.º 1
0
        public static T AddNode <T>(Vector2 position, BehaviorTree bt)
        {
            if (bt == null)
            {
                Debug.LogWarning("Can't add a node to the behavior trees, because the behavior trees are null.");
                return(default(T));
            }
            Node node = ScriptableObject.CreateInstance(typeof(T)) as Node;

            node.hideFlags = HideFlags.HideInHierarchy;

            node.Name     = BehaviorTreeEditorUtility.GenerateName <T>();
            node.comment  = node.Name;
            node.bt       = bt;
            bt.nodes      = ArrayUtility.Add <Node>(bt.nodes, node);
            node.position = new Rect(position.x, position.y, BehaviorTreeEditorStyles.NodeNormalWidth, BehaviorTreeEditorStyles.NodeNormalHeight);

            if (EditorUtility.IsPersistent(bt))
            {
                AssetDatabase.AddObjectToAsset(node, bt);
            }

            if (node is BehaviorTree)
            {
                node.position.width  = 150f;
                node.position.height = 45f;

                Root root = BehaviorTreeEditorUtility.AddNode <Root>(BehaviorTreeEditor.center, node as BehaviorTree);
                root.Name = "Root";
            }
            else if (node is Wait)
            {
                Wait wait = node as Wait;
                wait.tick    = 0.1f;
                wait.comment = "Wait: 0.1s";
            }

            AssetDatabase.SaveAssets();
            return((T)(object)node);
        }
Exemplo n.º 2
0
        public static void AreaPopup(string labelName, SerializedProperty areaProperty)
        {
            var areaIndex = -1;
            var areaNames = GameObjectUtility.GetNavMeshAreaNames();

            for (var i = 0; i < areaNames.Length; i++)
            {
                var areaValue = GameObjectUtility.GetNavMeshAreaFromName(areaNames[i]);

                if (areaValue == areaProperty.intValue)
                {
                    areaIndex = i;
                }
            }

            ArrayUtility.Add(ref areaNames, "");
            ArrayUtility.Add(ref areaNames, "Open Area Settings...");

            var rect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight);

            EditorGUI.BeginProperty(rect, GUIContent.none, areaProperty);

            EditorGUI.BeginChangeCheck();
            areaIndex = EditorGUI.Popup(rect, labelName, areaIndex, areaNames);

            if (EditorGUI.EndChangeCheck())
            {
                if (areaIndex >= 0 && areaIndex < areaNames.Length - 2)
                {
                    areaProperty.intValue = GameObjectUtility.GetNavMeshAreaFromName(areaNames[areaIndex]);
                }
                else if (areaIndex == areaNames.Length - 1)
                {
                    NavMeshEditorHelpers.OpenAreaSettings();
                }
            }

            EditorGUI.EndProperty();
        }
Exemplo n.º 3
0
        private void SelectDatabase()
        {
            string searchString = "Search...";

            QuestDatabase[] databases = EditorTools.FindAssets <QuestDatabase>();

            UtilityInstanceWindow.ShowWindow("Select Database", delegate() {
                searchString = EditorTools.SearchField(searchString);

                for (int i = 0; i < databases.Length; i++)
                {
                    if (!string.IsNullOrEmpty(searchString) && !searchString.Equals("Search...") && !databases[i].name.Contains(searchString))
                    {
                        continue;
                    }
                    GUIStyle style = new GUIStyle("button");
                    style.wordWrap = true;
                    if (GUILayout.Button(AssetDatabase.GetAssetPath(databases[i]), style))
                    {
                        database = databases[i];
                        ResetChildEditors();
                        Show();
                        UtilityInstanceWindow.CloseWindow();
                    }
                }
                GUILayout.FlexibleSpace();
                Color color         = GUI.backgroundColor;
                GUI.backgroundColor = Color.green;
                if (GUILayout.Button("Create"))
                {
                    QuestDatabase db = EditorTools.CreateAsset <QuestDatabase>(true);
                    if (db != null)
                    {
                        ArrayUtility.Add <QuestDatabase>(ref databases, db);
                    }
                }
                GUI.backgroundColor = color;
            });
        }
Exemplo n.º 4
0
        public void                       SetOverrideMotion(AnimatorState state, Motion motion)
        {
            if (m_Motions == null)
            {
                m_Motions = new StateMotionPair[] {}
            }
            ;
            for (int i = 0; i < m_Motions.Length; ++i)
            {
                if (m_Motions[i].m_State == state)
                {
                    m_Motions[i].m_Motion = motion;
                    return;
                }
            }

            StateMotionPair newPair;

            newPair.m_State  = state;
            newPair.m_Motion = motion;
            ArrayUtility.Add(ref m_Motions, newPair);
        }
Exemplo n.º 5
0
        int StrokeIndexField(int holeIndex, TeeBase.Info.Type teeType, int index, bool add, float xBoxes)
        {
            string[] names     = CourseBase.FreeTeesStrokeIndex(holeIndex, teeType);
            string   indexName = index.ToString();

            if (!ArrayUtility.Contains(names, indexName))
            {
                if (add)
                {
                    ArrayUtility.Add(ref names, indexName);

                    string[] newNames = CourseBase.HoleNames;
                    for (int i = 0; i < newNames.Length; ++i)
                    {
                        if (!ArrayUtility.Contains(names, newNames[i]))
                        {
                            ArrayUtility.RemoveAt(ref newNames, i);
                            i = -1;
                            continue;
                        }
                    }
                    names = newNames;
                }
                else
                {
                    indexName = names[0];
                }
            }

            int namesIndex = ArrayUtility.IndexOf(names, indexName);

            namesIndex = Popup("StrokeIndex", namesIndex, names, xBoxes);
            if (namesIndex >= 0)
            {
                int.TryParse(names[namesIndex], out index);
            }

            return(index);
        }
Exemplo n.º 6
0
 void CachePropertiesDrawer(bool clearCurrentCache = false)
 {
     if (selectedType == null)
     {
         return;
     }
     if (clearCurrentCache)
     {
         propertiesDrawerCache.Clear();
     }
     if (!propertiesDrawerCache.ContainsKey(selectedType))
     {
         propertiesDrawerCache.Add(selectedType, new EditablePropertyDrawer[0]);
     }
     EditablePropertyDrawer[] drawers = new EditablePropertyDrawer[0];
     for (int i = 0; i < selectedProperties.Length; i++)
     {
         EditablePropertyDrawer drawer = new EditablePropertyDrawer(selectedType, selectedProperties [i], OnApplyPropertyChanged, OnPropertyDelete);
         ArrayUtility.Add <EditablePropertyDrawer> (ref drawers, drawer);
     }
     propertiesDrawerCache [selectedType] = drawers;
 }
        public Keyframe[] GetPositionKeyframes()
        {
            Keyframe[] keyframes = xPos != null ? xPos.keys : (yPos != null ? yPos.keys : (zPos != null ? zPos.keys : new Keyframe[0]));

            bool addedFrames = false;

            if (yPos != null)
            {
                foreach (Keyframe k in yPos.keys)
                {
                    if (!HasKeyframe(ref keyframes, k.time))
                    {
                        ArrayUtility.Add <Keyframe>(ref keyframes, k);
                        addedFrames = true;
                    }
                }
            }

            if (zPos != null)
            {
                foreach (Keyframe k in zPos.keys)
                {
                    if (!HasKeyframe(ref keyframes, k.time))
                    {
                        ArrayUtility.Add <Keyframe>(ref keyframes, k);
                        addedFrames = true;
                    }
                }
            }

            if (addedFrames)
            {
                Array.Sort <Keyframe>(keyframes, delegate(Keyframe a, Keyframe b) {
                    return(a.time.CompareTo(b.time));
                });
            }

            return(keyframes);
        }
Exemplo n.º 8
0
    public override void OnInspectorGUI()
    {
        var rect = EditorGUILayout.GetControlRect(true, 30);

        base.OnInspectorGUI();
        var running = Application.isPlaying && Networker.IsConnected;
        var style   = new GUIStyle(EditorStyles.whiteLargeLabel)
        {
            richText = true, fontSize = 20
        };
        var label = string.Format("{0} [<color={2}>{1}</color>]",
                                  typeof(Networker),
                                  running ? "On" : "Off",
                                  running ? "green" : "red");

        EditorGUI.LabelField(rect, label, style);
        EditorGUI.DrawRect(rect, (running ? Color.cyan : Color.yellow) / 3f);

        string[] connectorNames = { }, handlerNames = { };

        connectors.Foreach(c => ArrayUtility.Add(ref connectorNames, c.Name));
        connectorIndex = EditorGUILayout.Popup("Connector", connectorIndex, connectorNames);
        if (connectorIndex < connectors.Length)
        {
            connTypeName.stringValue = connectors[connectorIndex].FullName;
        }

        handlers.Foreach(c => ArrayUtility.Add(ref handlerNames, c.Name));
        handlerIndex = EditorGUILayout.Popup("MessageHandler", handlerIndex, handlerNames);
        if (handlerIndex < handlers.Length)
        {
            handlerTypeName.stringValue = handlers[handlerIndex].FullName;
        }

        EditorGUILayout.LabelField(new GUIContent("[Server Address] ?", "Click menu [ NETWORK ] switch or config address!"),
                                   new GUIContent(NetworkConfiguration.Current.ToString()));

        serializedObject.ApplyModifiedProperties();
    }
        public override void OnInspectorGUI()
        {
            if (remainingQuality.Length > 0)
            {
                int selected = EditorGUILayout.Popup("Add Quality Settings", -1, remainingQualityNames);
                if (selected != -1)
                {
                    Undo.RecordObject(target, "Added new Quality Setting in LayerCUllDistance");

                    QualitySettingPostprocessProfileSwitch.QualitySettingEntry newEntry =
                        new QualitySettingPostprocessProfileSwitch.QualitySettingEntry();

                    newEntry.minimumQualitySetting = remainingQuality[selected];

                    ArrayUtility.Add(ref m_Target.settings, newEntry);

                    EditorUtility.SetDirty(m_Target);

                    ArrayUtility.RemoveAt(ref remainingQualityNames, selected);
                    ArrayUtility.RemoveAt(ref remainingQuality, selected);
                }
            }

            for (int i = 0; i < m_Target.settings.Length; ++i)
            {
                bool opened = EditorGUILayout.Foldout(m_OpenedSettings == i,
                                                      "Quality : " + QualitySettings.names[m_Target.settings[i].minimumQualitySetting]);

                if (opened)
                {
                    m_OpenedSettings = i;
                    DrawSetting(i);
                }
                else if (m_OpenedSettings == i)
                {
                    m_OpenedSettings = -1;
                }
            }
        }
        private void OnGUI()
        {
            // 途中でSceneViewが破棄される可能性があるのでチェックする
            if (_sceneView == null)
            {
                SetSceneView();

                if (_sceneView == null)
                {
                    return;
                }
            }

            _positionSize = 0;
            var cameras = Camera.allCameras;

            using (var scroll = new EditorGUILayout.ScrollViewScope(_scrollPosition))
            {
                _scrollPosition = scroll.scrollPosition;
                EditorGUILayout.BeginHorizontal();
                for (var i = 0; i < cameras.Length; i++)
                {
                    if (_previewCameras.Length <= i)
                    {
                        var pvc = EditorUtility.CreateGameObjectWithHideFlags(
                            "Preview Camera",
                            HideFlags.HideAndDontSave,
                            typeof(Camera),
                            typeof(Skybox)).GetComponent <Camera>();
                        pvc.enabled = false;
                        ArrayUtility.Add(ref _previewCameras, pvc);
                    }

                    DrawPreviewCamera(i, Camera.allCameras[i], _previewCameras[i]);
                }
                EditorGUILayout.EndHorizontal();
            }
        }
Exemplo n.º 11
0
        protected virtual void SelectDatabase()
        {
            string searchString = "Search...";

            T[] databases = UnityEditorUtility.GetAssetsOfType <T>(".asset");
            UtilityWindow.ShowWindow("Select Settings", delegate() {
                searchString = UnityEditorUtility.SearchField(searchString);

                for (int i = 0; i < databases.Length; i++)
                {
                    if (!string.IsNullOrEmpty(searchString) && !searchString.Equals("Search...") && !databases[i].name.Contains(searchString))
                    {
                        continue;
                    }
                    GUIStyle style = new GUIStyle("button");
                    style.wordWrap = true;
                    if (GUILayout.Button(AssetDatabase.GetAssetPath(databases[i]), style))
                    {
                        database = databases[i];
                        ResetChildEditors();
                        Show();
                        UtilityWindow.CloseWindow();
                    }
                }
                GUILayout.FlexibleSpace();
                Color color         = GUI.backgroundColor;
                GUI.backgroundColor = Color.green;
                if (GUILayout.Button("Create"))
                {
                    T db = AssetCreator.CreateAsset <T>(true);
                    if (db != null)
                    {
                        ArrayUtility.Add <T>(ref databases, db);
                    }
                }
                GUI.backgroundColor = color;
            });
        }
Exemplo n.º 12
0
        private void CachePropertiesDrawer(bool clearCurrentCache = false)
        {
            if (_selectedType == null)
            {
                return;
            }
            if (clearCurrentCache)
            {
                _propertiesDrawerCache.Clear();
            }
            if (!_propertiesDrawerCache.ContainsKey(_selectedType))
            {
                _propertiesDrawerCache.Add(_selectedType, new EditablePropertyDrawer[0]);
            }
            var drawers = new EditablePropertyDrawer[0];

            for (var i = 0; i < _selectedProperties.Length; i++)
            {
                var drawer = new EditablePropertyDrawer(_config, _selectedType, _selectedProperties[i], OnApplyPropertyChanged, OnPropertyDelete);
                ArrayUtility.Add(ref drawers, drawer);
            }
            _propertiesDrawerCache[_selectedType] = drawers;
        }
Exemplo n.º 13
0
    public override void Initialize(Object[] targets)
    {
        base.Initialize(targets);

        var sprites = new Object[0];

        foreach (var serializedProperty in targets.Select(t => new SerializedObject(t)).Select(so => so.FindProperty("m_ClipBindingConstant").FindPropertyRelative("pptrCurveMapping")))
        {
            for (var i = 0; i < serializedProperty.arraySize; i++)
            {
                var sprite = serializedProperty.GetArrayElementAtIndex(i).objectReferenceValue as Sprite;
                if (sprite != null)
                {
                    ArrayUtility.Add(ref sprites, sprite);

                    AssetPreview.GetAssetPreview(sprite);
                }
            }
        }

        hasSprites = sprites.Length != 0;
        m_Targets  = sprites;
    }
Exemplo n.º 14
0
    private void AddAircraft(string aircraftName)
    {
        if (!AllAircrafts.Instance)
        {
            Debug.LogError("AllAircrafts has not been created yet.");
            return;
        }

        Aircraft newAircraft = AircraftEditor.CreateAircraft(aircraftName);

        newAircraft.name = aircraftName;

        Undo.RecordObject(newAircraft, "Created new Aircraft");

        AssetDatabase.AddObjectToAsset(newAircraft, AllAircrafts.Instance);
        AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newAircraft));

        ArrayUtility.Add(ref AllAircrafts.Instance.aircrafts, newAircraft);

        EditorUtility.SetDirty(AllAircrafts.Instance);

        SetAllAircraftNames();
    }
Exemplo n.º 15
0
    private void AddItemSaveData(string description)
    {
        if (!AllItemSaveDatas.Instance)
        {
            Debug.LogError("AllItemSaveDatas has not been created yet.");
            return;
        }

        ItemSaveData newItemSaveData = ItemSaveDataEditor.CreateItemSaveData(description);

        newItemSaveData.name = description;

        Undo.RecordObject(newItemSaveData, "Created new ItemSaveData");

        AssetDatabase.AddObjectToAsset(newItemSaveData, AllItemSaveDatas.Instance);
        AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newItemSaveData));

        ArrayUtility.Add(ref AllItemSaveDatas.Instance.itemSaveDatas, newItemSaveData);

        EditorUtility.SetDirty(AllItemSaveDatas.Instance);

        SetAllItemSaveDataDescriptions();
    }
Exemplo n.º 16
0
 public override void DrawInspector()
 {
     base.DrawInspector();
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.BeginVertical();
     for (int i = 0; i < spline.triggerGroups.Length; i++)
     {
         DrawGroupGUI(i);
     }
     EditorGUILayout.Space();
     if (GUILayout.Button("New Group"))
     {
         RecordUndo("Add Trigger Group");
         TriggerGroup group = new TriggerGroup();
         group.name = "Trigger Group " + (spline.triggerGroups.Length + 1);
         ArrayUtility.Add(ref spline.triggerGroups, group);
     }
     EditorGUILayout.EndVertical();
     if (EditorGUI.EndChangeCheck())
     {
         SceneView.RepaintAll();
     }
 }
Exemplo n.º 17
0
    private void AddBuff(string buffName)
    {
        if (!AllBuffs.Instance)
        {
            Debug.LogError("AllBuffs has not been created yet.");
            return;
        }

        Buff newBuff = BuffEditor.CreateAircraft(buffName);

        newBuff.name = buffName;

        Undo.RecordObject(newBuff, "Created new Buff");

        AssetDatabase.AddObjectToAsset(newBuff, AllBuffs.Instance);
        AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newBuff));

        ArrayUtility.Add(ref AllBuffs.Instance.buffs, newBuff);

        EditorUtility.SetDirty(AllBuffs.Instance);

        SetAllBuffNames();
    }
Exemplo n.º 18
0
    protected override void ContextClicked()
    {
        if (m_EditedPack == null)
        {
            return;
        }

        GenericMenu menu = new GenericMenu();

        menu.AddItem(new GUIContent("Create New Folder..."), false, () =>
        {
            PackSettings.Node n = new PackSettings.Node()
            {
                name = "New Folder", parent = m_EditedPack.root
            };
            ArrayUtility.Add(ref m_EditedPack.root.children, n);
            Reload();
        });

        menu.ShowAsContext();

        Repaint();
    }
Exemplo n.º 19
0
        //Only when the object is unique, add it to the end of the array.
        //オブジェクトがユニークのときのみ、最後に追加する。
        public bool AddElement(GameObject go)
        {
            executing = true;

            bool added = false;

            if (objects == null)
            {
                objects = new GameObject[] { go };
                added   = true;
            }
            else
            {
                if (ArrayUtility.IndexOf(objects, go) < 0)
                {
                    ArrayUtility.Add(ref objects, go);
                    added = true;
                }
            }

            executing = false;
            return(added);
        }
Exemplo n.º 20
0
        private void SetGUIStyle()
        {
            if (windowSkin == null)
            {
                windowSkin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);

                iconButtonStyle = new GUIStyle
                {
                    name          = "ButtonStyle",
                    padding       = new RectOffset(0, 0, 0, 0),
                    margin        = new RectOffset(0, 0, 0, 0),
                    fixedWidth    = 16,
                    fixedHeight   = 16,
                    imagePosition = ImagePosition.ImageOnly,
                };

                GUIStyle[] customStyles = windowSkin.customStyles;
                ArrayUtility.Add(ref customStyles, iconButtonStyle);
                windowSkin.customStyles = customStyles;
            }

            GUI.skin = windowSkin;
        }
Exemplo n.º 21
0
        public AnimatorTransition AddStateMachineTransition(AnimatorStateMachine sourceStateMachine, AnimatorStateMachine destinationStateMachine)
        {
            undoHandler.DoUndo(this, "StateMachine Transition Added");

            AnimatorTransition[] transitionsVector = GetStateMachineTransitions(sourceStateMachine);
            AnimatorTransition   newTransition     = new AnimatorTransition();

            if (destinationStateMachine)
            {
                newTransition.destinationStateMachine = destinationStateMachine;
            }

            if (AssetDatabase.GetAssetPath(this) != "")
            {
                AssetDatabase.AddObjectToAsset(newTransition, AssetDatabase.GetAssetPath(this));
            }

            newTransition.hideFlags = HideFlags.HideInHierarchy;
            ArrayUtility.Add(ref transitionsVector, newTransition);
            SetStateMachineTransitions(sourceStateMachine, transitionsVector);

            return(newTransition);
        }
Exemplo n.º 22
0
        public override void DrawProperties(BloxEditorWindow ed, BloxBlockEd bdi)
        {
            TriggerEvent_Block _ = (TriggerEvent_Block)bdi.b;

            GUILayout.Label(TriggeEvent_BlockDrawer.GC_EventsVars);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(TriggeEvent_BlockDrawer.GC_Add, plyEdGUI.Styles.MiniButtonLeft, GUILayout.Width(30f)))
            {
                ArrayUtility.Add <BloxBlockEd>(ref bdi.paramBlocks, (BloxBlockEd)null);
                ArrayUtility.Add <BloxBlock>(ref bdi.b.paramBlocks, (BloxBlock)null);
                GUI.changed = true;
            }
            GUI.enabled = (bdi.paramBlocks.Length > 3);
            if (GUILayout.Button(TriggeEvent_BlockDrawer.GC_Remove, plyEdGUI.Styles.MiniButtonRight, GUILayout.Width(30f)))
            {
                ArrayUtility.RemoveAt <BloxBlockEd>(ref bdi.paramBlocks, bdi.paramBlocks.Length - 1);
                ArrayUtility.RemoveAt <BloxBlock>(ref bdi.b.paramBlocks, bdi.b.paramBlocks.Length - 1);
                GUI.changed = true;
            }
            GUI.enabled = true;
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 23
0
    void AddAnimation()
    {
        if (string.IsNullOrEmpty(animName))
        {
            return;
        }
        Simple2DAnimatorDataList part = new Simple2DAnimatorDataList();

        part.nameID     = animName;
        part.step       = step;
        part.loop       = true;
        part.active     = new bool[] { };
        part.sendInt    = new int[] { };
        part.sendFloat  = new float[] { };
        part.sendString = new string[] { };
        part.sprites    = new Sprite[] { };
        ArrayUtility.Add <Simple2DAnimatorDataList>(ref controller.animatorData.animatoins, part);
        ArrayUtility.Add <string>(ref animList, animName);
        animName  = string.Empty;
        index     = 0;
        tmp_index = 0;
        animIX    = animList.Length - 1;
    }
	} //End_Method

	private static void OnGUI(int instanceID, Rect selectionRect) {
		var pos = selectionRect;
		pos.x = pos.xMax - WIDTH;
		pos.width = WIDTH;

		var oldSelected = Selection.Contains(instanceID);
		var newSelected = GUI.Toggle(pos, oldSelected, string.Empty);

		if (newSelected == oldSelected) {
			return;
		} //End_If

		var instanceIDs = Selection.instanceIDs;

		if (newSelected) {
			ArrayUtility.Add(ref instanceIDs, instanceID);
		} //End_If
		else {
			ArrayUtility.Remove(ref instanceIDs, instanceID);
		} //End_If

		Selection.instanceIDs = instanceIDs;
	} //End_Method
Exemplo n.º 25
0
    void RefreshPacksList()
    {
        m_AvailablePacks  = new PackSettings[0];
        m_PacksNames      = new string[0];
        m_EditedPackIndex = -1;

        string[] packsIDs = AssetDatabase.FindAssets("t:PackSettings");

        foreach (string id in packsIDs)
        {
            PackSettings setting = AssetDatabase.LoadAssetAtPath <PackSettings>(AssetDatabase.GUIDToAssetPath(id));

            if (setting == m_EditedPack)
            {
                m_EditedPackIndex = m_AvailablePacks.Length;
            }

            ArrayUtility.Add(ref m_AvailablePacks, setting);
            ArrayUtility.Add(ref m_PacksNames, setting.name);
        }

        ArrayUtility.Add(ref m_PacksNames, "New...");
    }
    //
    private void AddCondition(string description)
    {
        if (!AllConditions.Instance)
        {
            Debug.LogError("AllConditions has not been created yet.");
            return;
        }

        Condition newCondition = ConditionEditor.CreateCondition(description);

        newCondition.name = description;

        Undo.RecordObject(newCondition, "Created new Condition");

        AssetDatabase.AddObjectToAsset(newCondition, AllConditions.Instance);
        AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newCondition));

        ArrayUtility.Add(ref AllConditions.Instance.conditions, newCondition);

        EditorUtility.SetDirty(AllConditions.Instance);

        SetAllConditionDescriptions();
    }
Exemplo n.º 27
0
    public override void OnInspectorGUI()
    {
        ITEM = (Items)target;

        showColor = EditorGUILayout.Foldout(showColor, "Rarity Colors");

        if (showColor)
        {
            EditorGUI.indentLevel++;
            for (int c = 0; c < ITEM.rarityColors.Length; c++)
            {
                GUILayout.BeginHorizontal();
                ITEM.rarityColors[c] = EditorGUILayout.ColorField("Rarity " + (c + 1), ITEM.rarityColors[c]);

                if (GUILayout.Button("-"))
                {
                    ArrayUtility.RemoveAt(ref ITEM.rarityColors, c);
                }
                GUILayout.EndHorizontal();
            }

            if (GUILayout.Button("Add Color"))
            {
                ArrayUtility.Add(ref ITEM.rarityColors, Color.white);
            }
            EditorGUI.indentLevel--;
        }



        GUILayout.Space(10);
        for (int i = 0; i < ITEM.weapons.Count; i++)
        {
            WeaponFamily wf = ITEM.weapons[i];//create reference to specific family
            FamilyDisplay(i, wf);
        }
    }
Exemplo n.º 28
0
        public void AddNewAction(System.Type actionType)
        {
            //create action
            var action = ScriptableObject.CreateInstance(actionType) as QuestAction;

            if (action == null)
            {
                return;
            }

            var sceneAction = action as QuestSceneAction;

            if (sceneAction != null)
            {
                var actionWrapper = (QuestSceneActionWrapper)ScriptableObject.CreateInstance(typeof(QuestSceneActionWrapper));
                actionWrapper._action     = sceneAction;
                actionWrapper._sceneAsset = AssetDatabase.LoadAssetAtPath <SceneAsset>(SceneManager.GetActiveScene().path);
                actionWrapper._actionType = MonoScript.FromScriptableObject(sceneAction);
                if (actionWrapper._sceneAsset == null)
                {
                    EditorUtility.DisplayDialog("Can't add Action", "You want to add a QuestSceneAction, the active scene must be saved first", "Ok");
                    return;
                }
                sceneAction._quest   = _quest;
                sceneAction._wrapper = actionWrapper;
                var manager = EpyllionWindow.GetSceneManager();
                manager._actions.Add(sceneAction);
                EditorUtility.SetDirty(manager);
                action = actionWrapper;
            }

            action.hideFlags = HideFlags.HideInHierarchy;
            action._quest    = _quest;
            AssetDatabase.AddObjectToAsset(action, _quest);
            ArrayUtility.Add(ref _quest.actions, action);
            EditorUtility.SetDirty(_quest);
        }
Exemplo n.º 29
0
 public bool CopySelectionToPasteboard()
 {
     UnityEngine.Object[] array         = new UnityEngine.Object[0];
     Vector3[]            monoPositions = new Vector3[0];
     using (List <UnityEditor.Graphs.Node> .Enumerator enumerator = this.selection.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             Node node = (Node)enumerator.Current;
             if (node is StateNode)
             {
                 ArrayUtility.Add <UnityEngine.Object>(ref array, (node as StateNode).state);
                 ArrayUtility.Add <Vector3>(ref monoPositions, new Vector3(node.position.x, node.position.y, 0f));
             }
             else if (node is StateMachineNode && (node as StateMachineNode).stateMachine != AnimatorControllerTool.tool.stateMachineGraph.parentStateMachine)
             {
                 ArrayUtility.Add <UnityEngine.Object>(ref array, (node as StateMachineNode).stateMachine);
                 ArrayUtility.Add <Vector3>(ref monoPositions, new Vector3(node.position.x, node.position.y, 0f));
             }
         }
     }
     foreach (int current in this.edgeGUI.edgeSelection)
     {
         EdgeInfo edgeInfo = this.stateMachineGraph.GetEdgeInfo(base.graph.edges[current]);
         foreach (TransitionEditionContext current2 in edgeInfo.transitions)
         {
             if (current2.transition != null)
             {
                 ArrayUtility.Add <UnityEngine.Object>(ref array, current2.transition);
                 ArrayUtility.Add <Vector3>(ref monoPositions, Vector3.zero);
             }
         }
     }
     Unsupported.CopyStateMachineDataToPasteboard(array, monoPositions, this.tool.animatorController, this.tool.selectedLayerIndex);
     return(array.Length > 0);
 }
Exemplo n.º 30
0
    // Enable Auto Save for a prefab and it's children.
    public static void EnableAutoSaveForSelectedPrefabRecursive(GameObject prefab)
    {
        ES2AutoSave autoSave = prefab.GetComponent <ES2AutoSave>();

        // Only add an Auto Save if this prefab doesn't already have one.
        if (autoSave == null)
        {
            // Add an ES2AutoSave to the prefab and add it to the Auto Save manager prefab.
            autoSave = ES2AutoSave.AddAutoSave(prefab, RandomColor(), AutoSaveComponentsAreHidden(), false, "");

            ES2AutoSaveGlobalManager globalManager = globalMgr;

            // Don't add prefab to prefab array if it's a child prefab.
            if (autoSave.transform.parent == null)
            {
                ArrayUtility.Add(ref globalManager.prefabArray, autoSave);
            }
        }

        foreach (Transform childTransform in prefab.transform)
        {
            EnableAutoSaveForSelectedPrefabRecursive(childTransform.gameObject);
        }
    }