Esempio n. 1
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        isDirty = false;

        control = (IControl)target;

        // Have the specific control class's implementation
        // draw any control-specific settings:
        DrawPrestateSettings();

        GUILayout.BeginVertical();

        //-------------------------------
        // Draw a nice separator:
        //-------------------------------
        GUILayout.Space(5.0f);

        GUILayout.BeginVertical("Toolbar");

        GUILayout.BeginHorizontal();
        GUILayout.Space(10.0f);
        GUILayout.Label("State/Element: ");
        GUILayout.FlexibleSpace();



        // Start keeping track of any changed values:
        BeginMonitorChanges();

        // Do the pre-state selection GUI, if any:
        control.DrawPreStateSelectGUI(curState, true);

        EndMonitorChanges();



        // Get the control's state names:
        stateNames = control.EnumStateElements();

        if (stateNames == null)
        {
            return;
        }

        // Cap our state to the number of states available:
        curState = Mathf.Min(curState, stateNames.Length - 1);

        // Choose the state we want to edit:
        curState = EditorGUILayout.Popup(curState, stateNames);

        GUILayout.FlexibleSpace();

        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
        //-------------------------------
        // End separator
        //-------------------------------


        // Keep track of any changed values:
        BeginMonitorChanges();

        // Do the post-state selection GUI, if any:
        control.DrawPostStateSelectGUI(curState);

        EndMonitorChanges();


        if (control is IPackableControl)
        {
            ShowSpriteSettings();
        }
        else
        {
            stateInfo = control.GetStateElementInfo(curState);
        }

        transitions = stateInfo.transitions;


        //-----------------------------------------
        // Draw our state label stuff:
        //-----------------------------------------
        if (stateInfo.stateLabel != null)
        {
            BeginMonitorChanges();
            DoStateLabel();
            EndMonitorChanges();
        }


        //-----------------------------------------
        // Draw our transition stuff:
        //-----------------------------------------
        if (transitions != null)
        {
            if (transitions.list != null)
            {
                if (transitions.list.Length > 0)
                {
                    DoTransitionStuff();
                }
            }
        }



        GUILayout.Space(10f);

        GUILayout.EndVertical();

        // Set dirty if anything changed:
        if (isDirty)
        {
            EditorUtility.SetDirty((MonoBehaviour)control);
        }
    }
Esempio n. 2
0
	public override void OnInspectorGUI()
	{
		base.OnInspectorGUI();

		isDirty = false;

		control = (IControl)target;

		// Have the specific control class's implementation
		// draw any control-specific settings:
		DrawPrestateSettings();

		GUILayout.BeginVertical();

		//-------------------------------		
		// Draw a nice separator:
		//-------------------------------		
		GUILayout.Space(5.0f);

		GUILayout.BeginVertical("Toolbar");

		GUILayout.BeginHorizontal();
		GUILayout.Space(10.0f);
		GUILayout.Label("State/Element: ");
		GUILayout.FlexibleSpace();

		
		
		// Start keeping track of any changed values:
		BeginMonitorChanges();
		
		// Do the pre-state selection GUI, if any:
		control.DrawPreStateSelectGUI(curState, true);

		EndMonitorChanges();



		// Get the control's state names:
		stateNames = control.EnumStateElements();

		if (stateNames == null)
			return;

		// Cap our state to the number of states available:
		curState = Mathf.Min(curState, stateNames.Length - 1);

		// Choose the state we want to edit:
		curState = EditorGUILayout.Popup(curState, stateNames);

		GUILayout.FlexibleSpace();

		GUILayout.EndHorizontal();
		GUILayout.EndVertical();
		//-------------------------------		
		// End separator
		//-------------------------------		


		// Keep track of any changed values:
		BeginMonitorChanges();

		// Do the post-state selection GUI, if any:
		control.DrawPostStateSelectGUI(curState);

		EndMonitorChanges();


		if (control is IPackableControl)
			ShowSpriteSettings();
		else
			stateInfo = control.GetStateElementInfo(curState);

		transitions = stateInfo.transitions;


		//-----------------------------------------
		// Draw our state label stuff:
		//-----------------------------------------
		if (stateInfo.stateLabel != null)
		{
			BeginMonitorChanges();
			DoStateLabel();
			EndMonitorChanges();
		}


		//-----------------------------------------
		// Draw our transition stuff:
		//-----------------------------------------
		if (transitions != null)
			if (transitions.list != null)
				if (transitions.list.Length > 0)
					DoTransitionStuff();



		GUILayout.Space(10f);

		GUILayout.EndVertical();

		// Set dirty if anything changed:
		if (isDirty)
			EditorUtility.SetDirty((MonoBehaviour)control);
	}
    public void OnGUI()
    {
        needRepaint = false;
        int oldState = curState;

        textureAreaBottom = 0;
        isDirty           = false;

        if (restarted)
        {
            selGO   = null;
            control = null;
            OnSelectionChange();
            restarted = false;
        }

        // See if our window size has changed:
        if (wndRect != position)
        {
            WindowResized();
        }

        // See if we need to update our selection:
        if (Selection.activeGameObject != selGO)
        {
            OnSelectionChange();
        }

//#if UNITY_IPHONE && !(UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9)
        if (Selection.activeGameObject != null)
        {
            control = (IControl)Selection.activeGameObject.GetComponent("IControl");
        }
//#endif

        // Bailout if we don't have valid values:
        if (null == (MonoBehaviour)control)
        {
            PrintNoSelectMsg();
            return;
        }



        // Start keeping track of any changed values:
        BeginMonitorChanges();

        // Do the pre-state selection GUI, if any:
        height = control.DrawPreStateSelectGUI(curState, false);

        EndMonitorChanges();



        // Get the control's state names:
        stateNames = control.EnumStateElements();
        if (stateNames == null)
        {
            return;
        }

        // Cap our state to the number of states available:
        if (stateNames != null)
        {
            curState = Mathf.Min(curState, stateNames.Length - 1);
        }
        else
        {
            curState = 0;
        }

        // Choose the state we want to edit:
        curState = GUILayout.Toolbar(curState, stateNames);

        // Reset our selected transition element
        // if the state selection changed:
        if (curState != oldState)
        {
            curFromTrans    = 0;
            curTransElement = 0;
        }



        // Keep track of any changed values:
        BeginMonitorChanges();

        // Do the post-state selection GUI, if any:
        height += control.DrawPostStateSelectGUI(curState);

        EndMonitorChanges();


        // Adjust our texture selection rect:
        tempRect    = texRect;
        tempRect.y += height;



        if (control is IPackableControl)
        {
            ShowSpriteSettings();
        }
        else
        {
            stateInfo = control.GetStateElementInfo(curState);
        }

        transitions = stateInfo.transitions;



        if (!Application.isPlaying)
        {
#if UNITY_IPHONE && !(UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9)
            // Box off our script selection and transition fields area:
            GUILayout.BeginArea(new Rect(0, textureAreaBottom, position.width, position.height - textureAreaBottom));
            GUILayout.FlexibleSpace();
#endif
            //-----------------------------------------
            // Draw script selection:
            //-----------------------------------------
            BeginMonitorChanges();
            control.DrawPreTransitionUI(curState, this);
            EndMonitorChanges();


            //-----------------------------------------
            // Draw our state label stuff:
            //-----------------------------------------
            if (stateInfo.stateLabel != null)
            {
                BeginMonitorChanges();
                DoStateLabel();
                EndMonitorChanges();
            }


            //-----------------------------------------
            // Draw our transition stuff:
            //-----------------------------------------
            if (transitions != null)
            {
                if (transitions.list != null)
                {
                    if (transitions.list.Length > 0)
                    {
                        DoTransitionStuff();
                    }
                }
            }



#if UNITY_IPHONE && !(UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9)
            // End the boxed off area for our script selection and transition fields.
            GUILayout.EndArea();
#endif
        }


        GUILayout.BeginVertical();
        GUILayout.Space(10f);
        GUILayout.EndVertical();

        // Set dirty if anything changed:
        if (isDirty)
        {
            EditorUtility.SetDirty((MonoBehaviour)control);
        }

        if (needRepaint)
        {
            Repaint();
        }
    }