Exemplo n.º 1
0
 void OnEnable()
 {
     GizmoState         = CurvySpline.Gizmos;
     CurvySpline.Gizmos = CurvySplineGizmos.Curve;
     mTexDelete         = CurvyResource.Load("deletesmall,12,12");
     mTexSave           = CurvyResource.Load("save,24,24");
     mTexGO             = CurvyResource.Load("gameobject,24,24");
     mDefaultMatTexture = new Texture2D(32, 32);
     for (int y = 0; y < 16; y++)
     {
         for (int x = 0; x < 16; x++)
         {
             mDefaultMatTexture.SetPixel(x, y, Color.white);
             mDefaultMatTexture.SetPixel(x + 16, y, Color.black);
             mDefaultMatTexture.SetPixel(x, y + 16, Color.black);
             mDefaultMatTexture.SetPixel(x + 16, y + 16, Color.white);
         }
     }
     mDefaultMatTexture.Apply();
     if (!previewGO)
     {
         previewGO           = new GameObject("ExportPreview");
         previewGO.hideFlags = HideFlags.HideAndDontSave;
         previewMeshRenderer = previewGO.AddComponent <MeshRenderer>();
         previewMeshFilter   = previewGO.AddComponent <MeshFilter>();
         if (!Mat)
         {
             Mat             = new Material(Shader.Find("Diffuse"));
             Mat.name        = "Preview";
             Mat.mainTexture = mDefaultMatTexture;
         }
         previewMeshRenderer.material = Mat;
     }
 }
Exemplo n.º 2
0
 static void LoadRuntimeSettings()
 {
     if (!PlayerPrefs.HasKey("Curvy_MaxCachePPU"))
     {
         SaveRuntimeSettings();
     }
     MaxCachePPU                = DTUtility.GetPlayerPrefs <int>("Curvy_MaxCachePPU", MaxCachePPU);
     SceneViewResolution        = DTUtility.GetPlayerPrefs <float>("Curvy_SceneViewResolution", SceneViewResolution);
     DefaultGizmoColor          = DTUtility.GetPlayerPrefs <Color>("Curvy_DefaultGizmoColor", DefaultGizmoColor);
     DefaultGizmoSelectionColor = DTUtility.GetPlayerPrefs <Color>("Curvy_DefaultGizmoSelectionColor", DefaultGizmoColor);
     DefaultInterpolation       = DTUtility.GetPlayerPrefs <CurvyInterpolation>("Curvy_DefaultInterpolation", DefaultInterpolation);
     GizmoControlPointSize      = DTUtility.GetPlayerPrefs <float>("Curvy_ControlPointSize", GizmoControlPointSize);
     GizmoOrientationLength     = DTUtility.GetPlayerPrefs <float>("Curvy_OrientationLength", GizmoOrientationLength);
     GizmoOrientationColor      = DTUtility.GetPlayerPrefs <Color>("Curvy_OrientationColor", GizmoOrientationColor);
     Gizmos      = DTUtility.GetPlayerPrefs <CurvySplineGizmos>("Curvy_Gizmos", Gizmos);
     SplineLayer = DTUtility.GetPlayerPrefs <int>("Curvy_SplineLayer", SplineLayer);
 }
 void OnEnable()
 {
     GizmoState = CurvyGlobalManager.Gizmos;
     CurvyGlobalManager.Gizmos = CurvySplineGizmos.Curve;
     
     
    
     if (!previewGO)
     {
         previewGO = new GameObject("ExportPreview");
         previewGO.hideFlags = HideFlags.HideAndDontSave;
         previewMeshRenderer = previewGO.AddComponent<MeshRenderer>();
         previewMeshFilter = previewGO.AddComponent<MeshFilter>();
         if (!Mat)
         {
             Mat = CurvyUtility.GetDefaultMaterial();
         }
         previewMeshRenderer.material = Mat;
     }
 }
        void OnEnable()
        {
            GizmoState = CurvyGlobalManager.Gizmos;
            CurvyGlobalManager.Gizmos = CurvySplineGizmos.Curve;



            if (!previewGO)
            {
                previewGO           = new GameObject("ExportPreview");
                previewGO.hideFlags = HideFlags.HideAndDontSave;
                previewMeshRenderer = previewGO.AddComponent <MeshRenderer>();
                previewMeshFilter   = previewGO.AddComponent <MeshFilter>();
                if (!Mat)
                {
                    Mat = CurvyUtility.GetDefaultMaterial();
                }
                previewMeshRenderer.material = Mat;
            }
        }
Exemplo n.º 5
0
        static void Load()
        {
            KeyBindings.Clear();
            if (!EditorPrefs.HasKey("Curvy_KeyBindings"))
            {
                Save();
            }
            GizmoColor             = String2Color(EditorPrefs.GetString("Curvy_GizmoColor", "1;0;0;1"));
            GizmoSelectionColor    = String2Color(EditorPrefs.GetString("Curvy_GizmoSelectionColor", "1;1;1;1"));
            GizmoControlPointSize  = EditorPrefs.GetFloat("Curvy_ControlPointSize", 0.15f);
            GizmoOrientationLength = EditorPrefs.GetFloat("Curvy_OrientationLength", 1);
            Gizmos             = (CurvySplineGizmos)EditorPrefs.GetInt("Curvy_Gizmos", (int)(CurvySplineGizmos.Curve | CurvySplineGizmos.Orientation));
            ToolbarLabels      = (Toolbar.LabelMode)EditorPrefs.GetInt("Curvy_ToolbarLabels", (int)Toolbar.LabelMode.Icon);
            ToolbarOrientation = (Toolbar.Orientation)EditorPrefs.GetInt("Curvy_ToolbarOrientation", (int)Toolbar.Orientation.Top);
            string kbcol = EditorPrefs.GetString("Curvy_KeyBindings");

            string[] binds = kbcol.Split('|');
            if (binds.Length > 1)
            {
                try
                {
                    for (int i = 0; i < binds.Length; i += 2)
                    {
                        string key = binds[i];
                        KeyBindings.Add(key, new EditorKeyDefinition(binds[i + 1]));
                    }
                }
                catch
                {
                    Debug.LogError("Curvy Preferences: Error loading Key Bindings! Resetting to defaults!");
                    EditorPrefs.DeleteKey("Curvy_KeyBindings");
                }
            }
            prefsLoaded = true;
            SetSplineGizmoSettings();
        }
Exemplo n.º 6
0
        public override void OnItemGUI(Rect itemRect)
        {
            bool b;
            bool v;

            SetSize(ref itemRect, 100,19);
            Background(itemRect, 100, 133);
            b = (Gizmos == 0);
            b = GUI.Toggle(itemRect, b, "None");
            if (b)
                Gizmos=0;
            // Curve
            NewLineBelow(ref itemRect);
            b=(Gizmos.HasFlag(CurvySplineGizmos.Curve));
            v = GUI.Toggle(itemRect, b, "Curve");
            if (b != v)
                Gizmos = Gizmos.Set<CurvySplineGizmos>(CurvySplineGizmos.Curve, v);
            // Approximation
            NewLineBelow(ref itemRect);
            b = (Gizmos.HasFlag(CurvySplineGizmos.Approximation));
            v = GUI.Toggle(itemRect, b, "Approximation");
            if (b != v)
                Gizmos = Gizmos.Set<CurvySplineGizmos>(CurvySplineGizmos.Approximation, v);
            // Orientation
            NewLineBelow(ref itemRect);
            b = (Gizmos.HasFlag(CurvySplineGizmos.Orientation));
            v = GUI.Toggle(itemRect, b, "Orientation");
            if (b != v)
                Gizmos = Gizmos.Set<CurvySplineGizmos>(CurvySplineGizmos.Orientation, v);
            // Tangents
            NewLineBelow(ref itemRect);
            b = (Gizmos.HasFlag(CurvySplineGizmos.Tangents));
            v = GUI.Toggle(itemRect, b, "Tangents");
            if (b != v)
                Gizmos = Gizmos.Set<CurvySplineGizmos>(CurvySplineGizmos.Tangents, v);
            // UserValues
            NewLineBelow(ref itemRect);
            b = (Gizmos.HasFlag(CurvySplineGizmos.UserValues));
            v = GUI.Toggle(itemRect, b, "User Values");
            if (b != v)
                Gizmos = Gizmos.Set<CurvySplineGizmos>(CurvySplineGizmos.UserValues, v);
            // Labels
            NewLineBelow(ref itemRect);
            b = (Gizmos.HasFlag(CurvySplineGizmos.Labels));
            v = GUI.Toggle(itemRect, b, "Labels");
            if (b != v)
                Gizmos = Gizmos.Set<CurvySplineGizmos>(CurvySplineGizmos.Labels, v);
        }
Exemplo n.º 7
0
        public override void OnItemGUI(Rect itemRect)
        {
            bool b;
            bool v;

            SetSize(ref itemRect, 100, 19);
            Background(itemRect, 100, 133);
            b = (Gizmos == 0);
            b = GUI.Toggle(itemRect, b, "None");
            if (b)
            {
                Gizmos = 0;
            }
            // Curve
            NewLineBelow(ref itemRect);
            b = (Gizmos.HasFlag(CurvySplineGizmos.Curve));
            v = GUI.Toggle(itemRect, b, "Curve");
            if (b != v)
            {
                Gizmos = Gizmos.Set <CurvySplineGizmos>(CurvySplineGizmos.Curve, v);
            }
            // Approximation
            NewLineBelow(ref itemRect);
            b = (Gizmos.HasFlag(CurvySplineGizmos.Approximation));
            v = GUI.Toggle(itemRect, b, "Approximation");
            if (b != v)
            {
                Gizmos = Gizmos.Set <CurvySplineGizmos>(CurvySplineGizmos.Approximation, v);
            }
            // Orientation
            NewLineBelow(ref itemRect);
            b = (Gizmos.HasFlag(CurvySplineGizmos.Orientation));
            v = GUI.Toggle(itemRect, b, "Orientation");
            if (b != v)
            {
                Gizmos = Gizmos.Set <CurvySplineGizmos>(CurvySplineGizmos.Orientation, v);
            }
            // Tangents
            NewLineBelow(ref itemRect);
            b = (Gizmos.HasFlag(CurvySplineGizmos.Tangents));
            v = GUI.Toggle(itemRect, b, "Tangents");
            if (b != v)
            {
                Gizmos = Gizmos.Set <CurvySplineGizmos>(CurvySplineGizmos.Tangents, v);
            }
            // UserValues
            NewLineBelow(ref itemRect);
            b = (Gizmos.HasFlag(CurvySplineGizmos.UserValues));
            v = GUI.Toggle(itemRect, b, "User Values");
            if (b != v)
            {
                Gizmos = Gizmos.Set <CurvySplineGizmos>(CurvySplineGizmos.UserValues, v);
            }
            // Labels
            NewLineBelow(ref itemRect);
            b = (Gizmos.HasFlag(CurvySplineGizmos.Labels));
            v = GUI.Toggle(itemRect, b, "Labels");
            if (b != v)
            {
                Gizmos = Gizmos.Set <CurvySplineGizmos>(CurvySplineGizmos.Labels, v);
            }
        }
Exemplo n.º 8
0
 void OnEnable()
 {
     GizmoState = CurvySpline.Gizmos;
     CurvySpline.Gizmos = CurvySplineGizmos.Curve;
     mTexDelete = CurvyResource.Load("deletesmall,12,12");
     mTexSave = CurvyResource.Load("save,24,24");
     mTexGO = CurvyResource.Load("gameobject,24,24");
     mDefaultMatTexture = new Texture2D(32, 32);
     for (int y = 0; y < 16; y++)
         for (int x = 0; x < 16; x++)
         {
             mDefaultMatTexture.SetPixel(x, y, Color.white);
             mDefaultMatTexture.SetPixel(x + 16, y, Color.black);
             mDefaultMatTexture.SetPixel(x, y + 16, Color.black);
             mDefaultMatTexture.SetPixel(x + 16, y + 16, Color.white);
         }
     mDefaultMatTexture.Apply();
     if (!previewGO)
     {
         previewGO = new GameObject("ExportPreview");
         previewGO.hideFlags = HideFlags.HideAndDontSave;
         previewMeshRenderer = previewGO.AddComponent<MeshRenderer>();
         previewMeshFilter = previewGO.AddComponent<MeshFilter>();
         if (!Mat)
         {
             Mat = new Material(Shader.Find("Diffuse"));
             Mat.name = "Preview";
             Mat.mainTexture = mDefaultMatTexture;
         }
         previewMeshRenderer.material = Mat;
     }
 }
Exemplo n.º 9
0
 static void Load()
 {
     KeyBindings.Clear();
     if (!EditorPrefs.HasKey("Curvy_KeyBindings"))
         Save();
     GizmoColor = String2Color(EditorPrefs.GetString("Curvy_GizmoColor", "1;0;0;1"));
     GizmoSelectionColor = String2Color(EditorPrefs.GetString("Curvy_GizmoSelectionColor", "1;1;1;1"));
     GizmoControlPointSize = EditorPrefs.GetFloat("Curvy_ControlPointSize", 0.15f);
     GizmoOrientationLength = EditorPrefs.GetFloat("Curvy_OrientationLength", 1);
     Gizmos = (CurvySplineGizmos)EditorPrefs.GetInt("Curvy_Gizmos", (int)(CurvySplineGizmos.Curve | CurvySplineGizmos.Orientation));
     ToolbarLabels = (Toolbar.LabelMode)EditorPrefs.GetInt("Curvy_ToolbarLabels", (int)Toolbar.LabelMode.Icon);
     ToolbarOrientation = (Toolbar.Orientation)EditorPrefs.GetInt("Curvy_ToolbarOrientation", (int)Toolbar.Orientation.Top);
     string kbcol = EditorPrefs.GetString("Curvy_KeyBindings");
     string[] binds = kbcol.Split('|');
     if (binds.Length > 1)
     {
         try
         {
             for (int i = 0; i < binds.Length; i += 2)
             {
                 string key = binds[i];
                 KeyBindings.Add(key, new EditorKeyDefinition(binds[i + 1]));
             }
         }
         catch
         {
             Debug.LogError("Curvy Preferences: Error loading Key Bindings! Resetting to defaults!");
             EditorPrefs.DeleteKey("Curvy_KeyBindings");
         }
     }
     prefsLoaded = true;
     SetSplineGizmoSettings();
 }