Example #1
0
 internal override bool ValidateParentStackType(IModeStack newStack)
 {
     if (newStack as T == null)
     {
         Debug.LogErrorFormat("Trying to push {0} mode to the wrong type of stack. Was {1}, should be {2}",
                              gameObject == null ? "[null game object]" : gameObject.name,
                              newStack == null ? "[null stack]" : newStack.GetType().ToString(),
                              typeof(T).ToString());;
         return(false);
     }
     return(true);
 }
Example #2
0
        internal override int GetChildCountRecursive(params ChannelID[] channelFilter)
        {
            IModeStack stack = this as IModeStack;

            if (stack == null)
            {
                return(0);
            }

            int result = 0;

            for (int i = 0; i < stack.ModeStack.Modes.Count; i++)
            {
                if (stack.ModeStack.Modes[i].CheckChannelFilter(channelFilter))
                {
                    result++;
                }
                result += stack.ModeStack.Modes[i].GetChildCountRecursive(channelFilter);
            }
            return(result);
        }
Example #3
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            //draw field for parent stack
            Mode targetMode = target as Mode;

            //use reflection to find the actual stack objects
            parentStack  = null;
            parentObject = null;
            FieldInfo[] fieldInfos = typeof(Mode).GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
            for (int i = 0; i < fieldInfos.Length; i++)
            {
                if (fieldInfos[i].Name == "ParentStack")
                {
                    parentStack  = fieldInfos[i].GetValue(targetMode) as IModeStack;
                    parentObject = parentStack as Object;
                }
            }

            //set label string
            if (parentStack == null)
            {
                result = " None";
            }
            else if (parentObject == null)
            {
                result = " " + parentStack.GetType().ToString();
            }
            else
            {
                result = " " + parentObject.name;
            }

            //draw a divider
            Rect r = EditorGUILayout.GetControlRect();

            r.y += r.height / 1.75f;
            ModeStackEditor.DrawDivider(r);

            //draw prefix
            Rect clickArea = EditorGUILayout.BeginHorizontal();

            EditorGUILayout.PrefixLabel("Parent Stack:");

            //handle click event
            Event current = Event.current;

            if (parentObject != null && clickArea.Contains(current.mousePosition))
            {
                if (current.type == EventType.MouseDown)
                {
                    if (current.clickCount == 1)
                    {
                        EditorGUIUtility.PingObject(parentObject);
                        current.Use();
                    }
                    else if (current.clickCount == 2)
                    {
                        Selection.activeObject = parentObject;
                        current.Use();
                    }
                }
            }

            //draw the field
            GUILayout.Button(result, EditorStyles.objectField);
            EditorGUILayout.EndHorizontal();
        }
Example #4
0
 public static List <Mode> GetModes(this IModeStack iStack, params ChannelID[] channelFilter)
 {
     return(iStack.ModeStack.GetModes(channelFilter));
 }
Example #5
0
 internal void ValidateOwner(IModeStack _owner)
 {
     owner = _owner;
 }
Example #6
0
 public static void RemoveAllSilent(this IModeStack iStack)
 {
     iStack.ModeStack.ValidateOwner(iStack);
     iStack.ModeStack.RemoveAllSilent();
 }
Example #7
0
 public static void RemoveModeSilent(this IModeStack iStack, Mode mode)
 {
     iStack.ModeStack.ValidateOwner(iStack);
     iStack.ModeStack.RemoveModeSilent(mode);
 }
Example #8
0
 public static void PushModeSilent(this IModeStack iStack, Mode newMode)
 {
     iStack.ModeStack.ValidateOwner(iStack);
     iStack.ModeStack.PushModeSilent(newMode);
 }
Example #9
0
 //bookkeeping functionality
 internal abstract bool ValidateParentStackType(IModeStack newStack);