예제 #1
0
 public Connector_Behavior Set_CB_Target(GameObject _CB_Target)
 {
     CB_Target = _CB_Target.GetComponent <Connector_Behavior>();
     Has_CB_Target_Been_Setup = true;
     return(CB_Target);
 }
예제 #2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        Connector_Behavior CB = (Connector_Behavior)target;

        CB.Attachment_Mode = EditorGUILayout.Toggle("Attachment Mode", CB.Attachment_Mode);
        if (!CB.Attachment_Mode)
        {
            CB.Has_Connector_Offset_Been_Found = false;
            if (CB.Attachment_Port_One != null)
            {
                CB.Attachment_Port_One = null;
            }
        }
        else
        {
            if (CB.Connection_Port_One != null && CB.Connection_Port_Two != null)
            {
                CB.Attachment_Mode = false;
            }
            else
            {
                if (CB.Attachment_Port_One != null || CB.Attachment_Port_Two != null)
                {
                    CB.Attachment_Mode_Options = EditorGUILayout.Toggle("Attachment Mode Options", CB.Attachment_Mode_Options);
                    if (CB.Attachment_Mode_Options)
                    {
                        CB.Change_Connector_Offset = EditorGUILayout.Toggle("Change Connector Offset", CB.Change_Connector_Offset);
                        if (CB.Change_Connector_Offset)
                        {
                            CB.Has_New_Connector_Offset_Been_Found = true;
                            CB.Connector_Offset = EditorGUILayout.Vector3Field("Connector Offset", CB.Connector_Offset);
                            if (!Reset_Connector_Offset)
                            {
                                CB.gameObject.transform.position = CB.Attachment_Port_One.gameObject.transform.position;
                                CB.Connector_Offset    = Vector3.zero;
                                Reset_Connector_Offset = true;
                            }
                            CB.gameObject.transform.position = CB.Attachment_Port_One.gameObject.transform.position + CB.Connector_Offset;
                            if (GUILayout.Button("Save New Connector Offset"))
                            {
                                CB.Change_Connector_Offset             = false;
                                CB.Has_New_Connector_Offset_Been_Found = false;
                                Reset_Connector_Offset = false;
                            }
                        }
                        else
                        {
                            Reset_Connector_Offset = false;
                        }
                    }
                }

                if (CB.Connection_Port_One == null)
                {
                    CB.Attachment_Port_One = EditorGUILayout.ObjectField("Attachment Port One", CB.Attachment_Port_One, typeof(GameObject), true) as GameObject;
                    if (!CB.Has_New_Connector_Offset_Been_Found)
                    {
                        if (CB.Attachment_Port_One != null && CB.Attachment_Port_One.gameObject.GetComponent <Platform_Behavior>() != null)
                        {
                            CB.Attachment_Port_One_PB = CB.Attachment_Port_One.gameObject.GetComponent <Platform_Behavior>();
                            if (CB.Connector_Offset != Vector3.zero || CB.Has_Connector_Offset_Been_Found)
                            {
                                CB.gameObject.transform.position = CB.Attachment_Port_One.gameObject.transform.position + CB.Connector_Offset;
                            }
                            if (!CB.Has_Connector_Offset_Been_Found)
                            {
                                CB.gameObject.transform.position   = CB.Attachment_Port_One.gameObject.transform.position;
                                CB.gameObject.transform.rotation   = CB.Attachment_Port_One.gameObject.transform.rotation;
                                CB.Has_Connector_Offset_Been_Found = true;
                            }
                        }
                    }
                }
            }
        }

        CB.Connection_Mode = EditorGUILayout.Toggle("Connection Mode (Platform(s) connects to connector)", CB.Connection_Mode);
        if (!CB.Connection_Mode)
        {
            if (CB.Connection_Port_One != null)
            {
                CB.CPO_List_Index = 0; DestroyImmediate(CB.Connection_Port_One, true);
            }
            if (CB.Connection_Port_Two != null)
            {
                CB.CPT_List_Index = 0; DestroyImmediate(CB.Connection_Port_Two, true);
            }
        }
        else
        {
            CB.PLB = GameObject.FindGameObjectWithTag("Scene Manager").GetComponent <Prefab_Loader_Behavior>();
            if (CB.PLB != null)
            {
                EditorGUILayout.LabelField("Connector Miscellaneous");
                if (GUILayout.Button("Rotate Connector Forty-Five Degrees Left"))
                {
                    CB.gameObject.transform.Rotate(0f, -45f, 0f);
                    if (CB.Connection_Port_One != null)
                    {
                        CB.Object_Rotation_Left_Or_Right(CB.Connection_Port_One, "Left");
                    }
                    if (CB.Connection_Port_Two != null)
                    {
                        CB.Object_Rotation_Left_Or_Right(CB.Connection_Port_Two, "Left");
                    }
                }
                if (GUILayout.Button("Rotate Connector Forty-Five Degrees Right"))
                {
                    CB.gameObject.transform.Rotate(0f, 45f, 0f);
                    if (CB.Connection_Port_One != null)
                    {
                        CB.Object_Rotation_Left_Or_Right(CB.Connection_Port_One, "Right");
                    }
                    if (CB.Connection_Port_Two != null)
                    {
                        CB.Object_Rotation_Left_Or_Right(CB.Connection_Port_Two, "Right");
                    }
                }

                EditorGUILayout.LabelField("Connector Ports");

                // CB.Connection_Port_One = EditorGUILayout.ObjectField("Connection Port One:", CB.Connection_Port_One, typeof(GameObject), true) as GameObject;
                if (CB.Attachment_Port_One == null)
                {
                    GUIContent Connection_Port_One = new GUIContent("Connection Port One");
                    CB.CPO_List_Index = EditorGUILayout.Popup(Connection_Port_One, CB.CPO_List_Index, CB.PLB.Prefab_String_Array);
                }

                bool Check_For_Connector_One_Change = CB.Check_For_Change(CB.CPO_List_Index, CB.COPI);
                if (Check_For_Connector_One_Change)
                {
                    CB.COPI = CB.CPO_List_Index;
                    if (CB.CPO_List_Index != 0)
                    {
                        CB.Instantiate_Prefab("Connection Port One");
                        CB.Attachment_Port_One_PB           = CB.Connection_Port_One.AddComponent <Platform_Behavior>();
                        CB.Attachment_Port_One_PB.CB_Target = CB.Attachment_Port_One_PB.Set_CB_Target(CB.gameObject);
                    }
                    else if (CB.Connection_Port_One != null && CB.CPO_List_Index == 0)
                    {
                        DestroyImmediate(CB.Connection_Port_One, true);
                        CB.Connector_One_Translation_Offset = Vector3.zero;
                    }
                }

                if (CB.Connection_Port_One != null)
                {
                    CB.Connector_One_Center_Point = CB.gameObject.transform.GetChild(0).GetComponent <Transform>();
                    if (CB.Connector_One_Translation_Offset == Vector3.zero)
                    {
                        CB.Connection_Port_One.transform.position = CB.Connector_One_Center_Point.position;
                    }
                    else
                    {
                        CB.Connection_Port_One.transform.position = CB.Connector_One_Center_Point.position + CB.Connector_One_Translation_Offset;
                    }
                    // CB.Connection_Port_One.transform.rotation = Connector_One_Center_Point.rotation;

                    CB.Enable_Port_One_Miscellaneous_Options = EditorGUILayout.Toggle("Port One Miscellaneous Settings", CB.Enable_Port_One_Miscellaneous_Options);
                    if (CB.Enable_Port_One_Miscellaneous_Options)
                    {
                        if (GUILayout.Button("Change Center Point"))
                        {
                            CB.Connection_Port_One.transform.position = CB.Change_Transform_Point(CB.COCP_Index, "Connector Port One", CB.Connection_Port_One.transform.position);
                            CB.COCP_Index += 1;
                            if (CB.COCP_Index < -1)
                            {
                                CB.COCP_Index = 0;
                            }
                            else if (CB.COCP_Index > CB.Connection_Port_One.transform.Find("Platform Connectors").transform.childCount - 1)
                            {
                                CB.COCP_Index = 0;
                            }
                        }
                    }

                    CB.Enable_Port_One_Transform_Options = EditorGUILayout.Toggle("Port One Transform Settings", CB.Enable_Port_One_Transform_Options);
                    if (CB.Enable_Port_One_Transform_Options)
                    {
                        // Rotate
                        if (GUILayout.Button("Rotate Forty-Five Degrees Left"))
                        {
                            CB.Object_Rotation_Left_Or_Right(CB.Connection_Port_One, "Left");
                        }
                        else if (GUILayout.Button("Rotate Forty-Five Degrees Right"))
                        {
                            CB.Object_Rotation_Left_Or_Right(CB.Connection_Port_One, "Right");
                        }

                        // Translate
                        CB.Connector_One_Translation_Offset = EditorGUILayout.Vector3Field("Translation Offset: ", CB.Connector_One_Translation_Offset);
                        // CB.Object_Translation(CB.Connection_Port_One, CB.Connector_One_Translation_Offset);
                    }
                }

                // CB.Connection_Port_Two = EditorGUILayout.ObjectField("Connection Port Two:", CB.Connection_Port_Two, typeof(GameObject), true) as GameObject;
                if (CB.Attachment_Port_Two == null)
                {
                    GUIContent Connection_Port_Two = new GUIContent("Connection Port Two");
                    CB.CPT_List_Index = EditorGUILayout.Popup(Connection_Port_Two, CB.CPT_List_Index, CB.PLB.Prefab_String_Array);
                }

                bool Check_For_Connector_Two_Change = CB.Check_For_Change(CB.CPT_List_Index, CB.CTPI);
                if (Check_For_Connector_Two_Change)
                {
                    CB.CTPI = CB.CPT_List_Index;
                    if (CB.CPT_List_Index != 0)
                    {
                        CB.Instantiate_Prefab("Connection Port Two");
                        CB.Attachment_Port_Two_PB           = CB.Connection_Port_Two.AddComponent <Platform_Behavior>();
                        CB.Attachment_Port_Two_PB.CB_Target = CB.Attachment_Port_Two_PB.Set_CB_Target(CB.gameObject);
                    }
                    else if (CB.Connection_Port_Two != null && CB.CPT_List_Index == 0)
                    {
                        DestroyImmediate(CB.Connection_Port_Two, true);
                        CB.Connector_Two_Translation_Offset = Vector3.zero;
                    }
                }

                if (CB.Connection_Port_Two != null)
                {
                    CB.Connector_Two_Center_Point = CB.gameObject.transform.GetChild(1).GetComponent <Transform>();
                    if (CB.Connector_Two_Translation_Offset == Vector3.zero)
                    {
                        CB.Connection_Port_Two.transform.position = CB.Connector_Two_Center_Point.position;
                    }
                    else
                    {
                        CB.Connection_Port_Two.transform.position = CB.Connector_Two_Center_Point.position + CB.Connector_Two_Translation_Offset;
                    }
                    // CB.Connection_Port_Two.transform.rotation = Connector_Two_Center_Point.rotation;

                    CB.Enable_Port_Two_Transform_Options = EditorGUILayout.Toggle("Port Two Transform Settings", CB.Enable_Port_Two_Transform_Options);
                    if (CB.Enable_Port_Two_Transform_Options)
                    {
                        // Rotate
                        if (GUILayout.Button("Rotate Forty-Five Degrees Left"))
                        {
                            CB.Object_Rotation_Left_Or_Right(CB.Connection_Port_Two, "Left");
                        }
                        else if (GUILayout.Button("Rotate Forty-Five Degrees Right"))
                        {
                            CB.Object_Rotation_Left_Or_Right(CB.Connection_Port_Two, "Right");
                        }

                        // Translate
                        CB.Connector_Two_Translation_Offset = EditorGUILayout.Vector3Field("Translation Offset: ", CB.Connector_Two_Translation_Offset);
                        // CB.Object_Translation(CB.Connection_Port_Two, CB.Connector_Two_Translation_Offset);
                    }
                }
            }
        }
    }