Esempio n. 1
0
 void OnDestroy()
 {
     if (primitiveIndex >= 0)
     {
         if (!EditorUtility.DisplayDialog("Keep changes?", "Do you want to apply the primitive to the spline ?", "Apply", "Revert"))
         {
             primitives[primitiveIndex].Close();
         }
     }
     if (presetIndex >= 0)
     {
         if (!EditorUtility.DisplayDialog("Keep changes?", "Do you want to apply the preset to the spline ?", "Apply", "Revert"))
         {
             presets[presetIndex].Cancel();
         }
     }
     presetIndex    = -1;
     primitiveIndex = -1;
     SplineUser[] users = computer.GetComponents <SplineUser>();
     foreach (SplineUser user in users)
     {
         user.Rebuild(true);
     }
     computer.Rebuild();
     ((SplineEditor)editor).Refresh();
     SceneView.RepaintAll();
     primitives = null;
     presets    = null;
     newPreset  = null;
 }
Esempio n. 2
0
 protected void UpdateUsers()
 {
     if (computer == null)
     {
         return;
     }
     SplineUser[] users = computer.GetComponents <SplineUser>();
     foreach (SplineUser user in users)
     {
         user.Rebuild(true);
     }
     computer.Rebuild();
 }
Esempio n. 3
0
 protected virtual void Update()
 {
     if (computer == null)
     {
         return;
     }
     SplineUser[] users = computer.GetComponents <SplineUser>();
     foreach (SplineUser user in users)
     {
         user.Rebuild(true);
     }
     computer.Rebuild();
     SceneView.RepaintAll();
 }
Esempio n. 4
0
        void RenderMorph(int index, string name, SplineComputer.Morph morph)
        {
            SplineComputer computer = ((SplineComputer)editor.target);

            if (currentMorph == index)
            {
                GUI.color = Color.green;
            }
            GUILayout.Box("", GUILayout.Height(50), GUILayout.Width(position.width - 20));
            GUI.color = Color.white;
            Rect boxRect = GUILayoutUtility.GetLastRect();

            GUI.BeginGroup(boxRect);
            GUI.Label(new Rect(10, 5, boxRect.width - 40, 20), name);
            if (editShapeMode && currentMorph == index)
            {
                if (GUI.Button(new Rect(boxRect.width - 55, 5, 50, 20), "Cancel"))
                {
                    currentMorph  = -1;
                    editShapeMode = false;
                    morph.SetWeight(index, morph.GetWeight(index));
                }
            }
            else
            {
                if (GUI.Button(new Rect(boxRect.width - 25, 5, 20, 20), "x"))
                {
                    if (EditorUtility.DisplayDialog("Remove morph state", "Do you want to remove this morph state?", "Yes", "No"))
                    {
                        morph.SetWeight(index, 0f);
                        morph.RemoveChannel(index);
                        GUI.EndGroup();
                        return;
                    }
                }
            }
            if (currentMorph == index)
            {
                if (GUI.Button(new Rect(10, 25, boxRect.width / 3f, 20), "Save Shape"))
                {
                    currentMorph = -1;
                    morph.CaptureSnapshot(index);
                    editShapeMode = false;
                }
                GUI.Label(new Rect(20 + boxRect.width / 3f, 30, boxRect.width / 1.5f, 30), "Editing shape (weight is 100%)");
                GUI.EndGroup();
                return;
            }
            if (GUI.Button(new Rect(10, 25, boxRect.width / 3f, 20), "Edit Shape"))
            {
                currentMorph  = index;
                editShapeMode = true;
                computer.SetPoints(morph.GetSnapshot(index), SplineComputer.Space.Local);
                computer.Rebuild();
            }
            if (index == 0)
            {
                GUI.EndGroup();
                return;
            }
            GUI.Label(new Rect(20 + boxRect.width / 3f, 20, 50, 30), "Weight:");
            float weight     = morph.GetWeight(index);
            float lastWeight = weight;

            weight = GUI.HorizontalSlider(new Rect(20 + boxRect.width / 3f, 30, boxRect.width / 2.5f, 30), weight, 0f, 1f);
            string strWeight = weight.ToString();

            strWeight = GUI.TextField(new Rect(30 + boxRect.width / 3f + boxRect.width / 2.5f, 30, boxRect.width / 8, 16), strWeight);
            float.TryParse(strWeight, out weight);
            if (weight != lastWeight)
            {
                morph.SetWeight(index, weight);
            }
            GUI.EndGroup();
        }