Example #1
0
        public static void CreateController()
        {
            string path = AssetDatabase.GetAssetPath(Selection.activeObject);

            if (path == "")
            {
                path = "Assets";
            }
            else if (Path.GetExtension(path) != "")
            {
                path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), "");
            }

            if (path.Substring(0, 6) != "Assets")
            {
                EditorUtility.DisplayDialog("Please select a target folder first", "Error", "OK");
                return;
            }

            ControllerAsset asset = ScriptableObject.CreateInstance <ControllerAsset>();

            asset.controller = new Controller("New Camera Controller");

            HistoryPose node = new HistoryPose();

            node.editorPos = new Vector2(-200, 0);
            asset.controller.AddPoseNode(node);
            asset.controller.final.Final.input = node;
            asset.Save();

            path = AssetDatabase.GenerateUniqueAssetPath(path + "/New Camera Controller.asset");
            AssetDatabase.CreateAsset(asset, path);
            AssetDatabase.SaveAssets();
        }
Example #2
0
        public static void CreateController(Controller controller)
        {
            string name = controller.Name.value.value_str;

            if (string.IsNullOrEmpty(name))
            {
                name = "New Camera Controller";
            }
            string path = AssetDatabase.GetAssetPath(Selection.activeObject);

            if (path == "")
            {
                path = "Assets";
            }
            else if (Path.GetExtension(path) != "")
            {
                path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), "");
            }

            if (path.Substring(0, 6) != "Assets")
            {
                EditorUtility.DisplayDialog("Please select a target folder first", "Error", "OK");
                return;
            }

            ControllerAsset asset = ScriptableObject.CreateInstance <ControllerAsset>();

            asset.controller = controller;
            asset.Save();
            asset.controller = null;

            path = AssetDatabase.GenerateUniqueAssetPath(path + "/" + name + ".asset");
            AssetDatabase.CreateAsset(asset, path);
            AssetDatabase.SaveAssets();
        }
Example #3
0
        public override void OnInspectorGUI()
        {
            if (skin == null)
            {
                skin = Resources.Load <GUISkin>("GUI/EditorSkin") as GUISkin;
            }

            Rect rect;

            GUILayout.Space(10);

            rect = EditorGUILayout.GetControlRect(false, 20);
            Rect _r = rect;

            _r.width = 132;
            _r.y    -= 3;
            EditorGUI.DropShadowLabel(_r, "Camera Controller");
            //rect = EditorGUILayout.GetControlRect(false, 20);
            rect.xMax -= 15;
            rect.xMin  = rect.xMax - 100;

            if (GUI.Button(rect, "Edit >>"))
            {
                ControllerAsset asset = (target as ControllerAsset);
                if (asset != null)
                {
                    asset.Load();
                    CameraForgeWindow.asset = asset;
                    CameraForgeWindow.Init();
                    CameraForgeWindow.current = asset.controller;
                }
            }
        }