Пример #1
0
    void Initialize()
    {
        Name = "UnnamedArmy";
        Food = Mathf.Floor(Random.value * Global.MAXIMUM_FOOD);

        // Create a drawer.
        drawer = new EntityDrawer(transform);

        //Attempt to wire the SelectionInterface.
        SelectionInterface = transform.GetComponent <SelectableObj>();
        if (SelectionInterface == null)
        {
            throw new UnityException("Failed to link Army Entity to a SelectionInterface.");
        }
        else
        {
            WireSelectionInterface();
        }

        //Present UI Components.
    }
        protected void DrawComponentArrayGUI(List <IComponent> components)
        {
            var unfoldedComponents = EntityDrawer.GetUnfoldedComponents(_contextName, _totalNumberOfComponents);

            for (var i = 0; i < components.Count; i++)
            {
                var index = GetComponentIndex(components[i]);
                if (components[i] == null || index == -1)
                {
                    continue;
                }

                EntityDrawer.DrawComponent(
                    unfoldedComponents,
                    _contextName,
                    _totalNumberOfComponents,
                    index,
                    components[i],
                    OnComponentRemoved,
                    OnComponentChanged);
            }
        }
Пример #3
0
        public override void OnInspectorGUI()
        {
            var binaryBlueprint = ((BinaryBlueprint)target);

            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.LabelField("Blueprint", EditorStyles.boldLabel);
                binaryBlueprint.name = EditorGUILayout.TextField("Name", binaryBlueprint.name);

                if (_context != null)
                {
                    EntitasEditorLayout.BeginHorizontal();
                    {
                        _contextIndex = EditorGUILayout.Popup(_contextIndex, _allContextNames);

                        if (GUILayout.Button("Switch Context"))
                        {
                            switchToContext();
                        }
                    }
                    EntitasEditorLayout.EndHorizontal();

                    EntityDrawer.DrawComponents(_context, _entity, true);
                }
                else
                {
                    EditorGUILayout.LabelField("No contexts found!");
                }
            }
            var changed = EditorGUI.EndChangeCheck();

            if (changed)
            {
                binaryBlueprint.Serialize(_entity);
                AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(target), binaryBlueprint.name);
                EditorUtility.SetDirty(target);
            }
        }
        public override void OnInspectorGUI()
        {
            var BlueprintScriptableObject = ((BlueprintScriptableObject)target);

            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.LabelField("Blueprint", EditorStyles.boldLabel);

                if (_context != null)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        _contextIndex = EditorGUILayout.Popup(_contextIndex, _allContextNames);
                        if (_previousContextIndex != _contextIndex)
                        {
                            _previousContextIndex = _contextIndex;
                            SwitchToContext(_contextIndex);
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    EntityDrawer.DrawComponents(_context, _entity);
                }
                else
                {
                    EditorGUILayout.LabelField("No contexts found!");
                }
            }
            var changed = EditorGUI.EndChangeCheck();

            if (changed || previousName != BlueprintScriptableObject.name)
            {
                previousName = BlueprintScriptableObject.name;
                //UpdateBlueprintLayout ();
                UpdateBlueprint();
                EditorUtility.SetDirty(BlueprintScriptableObject);
            }
        }
Пример #5
0
 //Start Delegation
 private void Initialize()
 {
     Name   = "NoMansLand";
     Food   = Mathf.Floor(Random.value * Global.MAXIMUM_FOOD);
     drawer = new EntityDrawer(transform.GetChild(0));
 }
Пример #6
0
 void Awake()
 {
     EntityDrawer.Initialize();
 }