예제 #1
0
 void drawRotateGUI()
 {
     AraleEditorTool.BeginContents();
     EditorGUILayout.BeginHorizontal();
     if (GUILayout.Button(mAIBone.xMin == 0 ? "xMin" : mAIBone.xMin.ToString(), GUILayout.Width(80)))
     {
         mAIBone.xMin = mAIBone.transform.localRotation.eulerAngles.x;
     }
     if (GUILayout.Button(mAIBone.xMax == 0 ? "xMax" : mAIBone.xMax.ToString(), GUILayout.Width(80)))
     {
         mAIBone.xMax = mAIBone.transform.localRotation.eulerAngles.x;
     }
     EditorGUILayout.EndHorizontal();
     EditorGUILayout.BeginHorizontal();
     if (GUILayout.Button(mAIBone.yMin == 0 ? "yMin" : mAIBone.yMin.ToString(), GUILayout.Width(80)))
     {
         mAIBone.yMin = mAIBone.transform.localRotation.eulerAngles.y;
     }
     if (GUILayout.Button(mAIBone.yMax == 0 ? "yMax" : mAIBone.yMax.ToString(), GUILayout.Width(80)))
     {
         mAIBone.yMax = mAIBone.transform.localRotation.eulerAngles.y;
     }
     EditorGUILayout.EndHorizontal();
     EditorGUILayout.BeginHorizontal();
     if (GUILayout.Button(mAIBone.zMin == 0 ? "zMin" : mAIBone.zMin.ToString(), GUILayout.Width(80)))
     {
         mAIBone.zMin = mAIBone.transform.localRotation.eulerAngles.z;
     }
     if (GUILayout.Button(mAIBone.zMax == 0 ? "zMax" : mAIBone.zMax.ToString(), GUILayout.Width(80)))
     {
         mAIBone.zMax = mAIBone.transform.localRotation.eulerAngles.z;
     }
     EditorGUILayout.EndHorizontal();
     AraleEditorTool.EndContents();
 }
예제 #2
0
 void drawLengthGUI()
 {
     AraleEditorTool.BeginContents();
     EditorGUILayout.BeginHorizontal();
     if (GUILayout.Button(mAIBone.length > 0?"解锁":"锁定", GUILayout.Width(80)))
     {
         onLockLengthClick();
     }
     EditorGUILayout.LabelField("length", GUILayout.Width(30));
     mAIBone.length = EditorGUILayout.FloatField(mAIBone.length);
     EditorGUILayout.LabelField("min", GUILayout.Width(30));
     mAIBone.minLength = EditorGUILayout.FloatField(mAIBone.minLength);
     EditorGUILayout.LabelField("max", GUILayout.Width(30));
     mAIBone.maxLength = EditorGUILayout.FloatField(mAIBone.maxLength);
     mAIBone.length    = Mathf.Clamp(mAIBone.length, mAIBone.minLength, mAIBone.maxLength);
     EditorGUILayout.EndHorizontal();
     AraleEditorTool.EndContents();
 }
예제 #3
0
 // Update is called once per frame
 public override void OnInspectorGUI()
 {
     mAnimAction.mActionName = EditorGUILayout.TextField("ActionName", mAnimAction.mActionName);
     if (AraleEditorTool.DrawHeader("action-info", "ACTION-INFO"))
     {
         AraleEditorTool.BeginContents();
         for (int i = 0; i < mAnimAction.actions.Count; ++i)
         {
             drawActionInspector(i);
         }
         GUILayout.Space(10);
         if (GUILayout.Button("添加", GUILayout.Width(80)))
         {
             onAddClick();
         }
         AraleEditorTool.EndContents();
     }
 }
예제 #4
0
    public override void OnInspectorGUI()
    {
        AraleEditorTool.BeginContents();
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("设置为根", GUILayout.Width(80)))
        {
            onRootClick();
        }
        if (GUILayout.Button("骨骼分裂", GUILayout.Width(80)))
        {
            onDivideClick();
        }
        EditorGUILayout.EndHorizontal();
        AraleEditorTool.EndContents();

        drawLengthGUI();
        drawRotateGUI();
        refreshSceneView();
    }
예제 #5
0
        void drawActionInspector(int idx)
        {
            AnimAction.Action action = mAnimAction.actions[idx];
            if (AraleEditorTool.DrawHeader("" + idx + ":" + action.mType, "ACTION" + idx))
            {
                AraleEditorTool.BeginContents();
                action.mType   = (AnimAction.ActionType)EditorGUILayout.EnumPopup("类型", action.mType);
                action.mMask   = (AnimAction.ActionMask)EditorGUILayout.EnumMaskField("过滤器", action.mMask);
                action.mEnable = EditorGUILayout.Toggle("是否可用", action.mEnable);
                switch (action.mType)
                {
                case AnimAction.ActionType.Event:
                    drawEventAction(action);
                    break;

                case AnimAction.ActionType.Move:
                    drawMoveAction(action);
                    break;

                case AnimAction.ActionType.Scale:
                    drawScaleAction(action);
                    break;

                case AnimAction.ActionType.Rotate:
                    drawRotateAction(action);
                    break;

                case AnimAction.ActionType.Alpha:
                    drawAlphaAction(action);
                    break;

                default:
                    break;
                }
                if (GUILayout.Button("删除", GUILayout.Width(80)))
                {
                    onDelClick(idx);
                }
                AraleEditorTool.EndContents();
            }
        }
예제 #6
0
    /// <summary>
    /// Draw the specified sprite.
    /// </summary>

    public static void DrawTexture(Texture2D tex, Rect rect, Rect uv, Color color, Material mat)
    {
        int w = Mathf.RoundToInt(tex.width * uv.width);
        int h = Mathf.RoundToInt(tex.height * uv.height);

        // Create the texture rectangle that is centered inside rect.
        Rect outerRect = rect;

        outerRect.width  = w;
        outerRect.height = h;

        if (outerRect.width > 0f)
        {
            float f = rect.width / outerRect.width;
            outerRect.width  *= f;
            outerRect.height *= f;
        }

        if (rect.height > outerRect.height)
        {
            outerRect.y += (rect.height - outerRect.height) * 0.5f;
        }
        else if (outerRect.height > rect.height)
        {
            float f = rect.height / outerRect.height;
            outerRect.width  *= f;
            outerRect.height *= f;
        }

        if (rect.width > outerRect.width)
        {
            outerRect.x += (rect.width - outerRect.width) * 0.5f;
        }

        // Draw the background
        AraleEditorTool.DrawTiledTexture(outerRect, AraleEditorTool.backdropTexture);

        // Draw the sprite
        GUI.color = color;

        if (mat == null)
        {
            GUI.DrawTextureWithTexCoords(outerRect, tex, uv, true);
        }
        else
        {
            // NOTE: There is an issue in Unity that prevents it from clipping the drawn preview
            // using BeginGroup/EndGroup, and there is no way to specify a UV rect... le'suq.
            UnityEditor.EditorGUI.DrawPreviewTexture(outerRect, tex, mat);
        }
        GUI.color = Color.white;

        // Draw the lines around the sprite
        Handles.color = Color.black;
        Handles.DrawLine(new Vector3(outerRect.xMin, outerRect.yMin), new Vector3(outerRect.xMin, outerRect.yMax));
        Handles.DrawLine(new Vector3(outerRect.xMax, outerRect.yMin), new Vector3(outerRect.xMax, outerRect.yMax));
        Handles.DrawLine(new Vector3(outerRect.xMin, outerRect.yMin), new Vector3(outerRect.xMax, outerRect.yMin));
        Handles.DrawLine(new Vector3(outerRect.xMin, outerRect.yMax), new Vector3(outerRect.xMax, outerRect.yMax));

        // Sprite size label
        string text = string.Format("Texture Size: {0}x{1}", w, h);

        EditorGUI.DropShadowLabel(GUILayoutUtility.GetRect(Screen.width, 18f), text);
    }